本文整理汇总了Python中actions.Actions.update_gestures方法的典型用法代码示例。如果您正苦于以下问题:Python Actions.update_gestures方法的具体用法?Python Actions.update_gestures怎么用?Python Actions.update_gestures使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类actions.Actions
的用法示例。
在下文中一共展示了Actions.update_gestures方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Listener
# 需要导入模块: from actions import Actions [as 别名]
# 或者: from actions.Actions import update_gestures [as 别名]
class Listener(EventDispatcher):
"""
listener function that queries kivy for touch events, builds the gesture
and dispatch it through the actions singleton.
"""
def __init__(self, config, gestures, el, *args, **kwarg):
"""
:param config: string containing the path to the action configuration
:param gestures: string containing the path to the gestures configuration
"""
super(EventDispatcher, self).__init__(*args, **kwarg)
self._event_loop = el
self._gdb = GestureDatabase()
self._actions = Actions(config, gestures)
self.update_devices()
self._multitouches = []
def update_devices(self):
log.debug('update_devices()')
context = pyudev.Context()
for device in context.list_devices(subsystem='input', ID_INPUT_MOUSE=True):
if device.sys_name.startswith('event'):
if 'PRODUCT' in device.parent.keys():
self._actions.update_gestures(device.parent['PRODUCT'])
for gest_n, gest_r in self._actions.get_gestures().iteritems():
for g in gest_r:
g = self._gdb.str_to_gesture(g)
g.normalize()
g.name = gest_n
self._gdb.add_gesture(g)
def on_touch_down(self, touch):
"""
listening function executed at begining of touch event
builds the gesture
"""
self._multitouches.append(touch)
touch.ud['line'] = Line(points=(touch.sx, touch.sy))
return True
def on_touch_move(self, touch):
"""
listening function executed during touch event
store points of the gesture
"""
# store points of the touch movement
try:
touch.ud['line'].points += [touch.sx, touch.sy]
return True
except (KeyError), e:
pass