当前位置: 首页>>代码示例>>Python>>正文


Python Actions.update_gestures方法代码示例

本文整理汇总了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
开发者ID:guyzmo,项目名称:kitt,代码行数:53,代码来源:listener.py


注:本文中的actions.Actions.update_gestures方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。