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


Python Action.click方法代码示例

本文整理汇总了Python中action.Action.click方法的典型用法代码示例。如果您正苦于以下问题:Python Action.click方法的具体用法?Python Action.click怎么用?Python Action.click使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在action.Action的用法示例。


在下文中一共展示了Action.click方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ActionListener

# 需要导入模块: from action import Action [as 别名]
# 或者: from action.Action import click [as 别名]
class ActionListener(Leap.Listener):

    debug = True
    SCROLL_THRESHOLD = 5
    AVG = 10
    count = 0
    action = None
    use_vertscroll = True
    roll_offset = math.pi/2 - .8
    vert_scroll_limit = math.pi/8
    last_click = 0
    clicked = False
    
    def on_init(self, controller):
        controller.set_policy_flags(Leap.Controller.POLICY_BACKGROUND_FRAMES)
        self.action = Action(controller)
        print "Initialized"

    def on_connect(self, controller):
        print "Connected" 

    def on_frame(self, controller):
        if (self.count == self.AVG):
            valid_fingers = 0
            average = Leap.Vector()

            for i in range(0, self.AVG - 1):
                index_finger = controller.frame(i).fingers.finger_type(Finger.TYPE_INDEX)[0]
#                index_finger = indexFingerList[0]
                 
                pinky_finger = controller.frame(i).fingers.finger_type(Finger.TYPE_PINKY)[0]
                #pinky_finger = pinky_fingerList[0]                 

                if(pinky_finger.is_valid and pinky_finger.direction.z < 0):
                    if(time.time() - self.last_click > 1):
                        print "last %d" , self.last_click
                        print "this %d" , time.time()
                        self.action.click(index_finger)
                        self.clicked = True
                        self.last_click = time.time()
                        
                if(not pinky_finger.is_valid or not pinky_finger.direction.z < 0):
                    if(self.clicked == True):
                        self.clicked = False
                        self.action.unclick(index_finger)        
                 
                if (index_finger.is_valid and index_finger.direction.z < 0):
                    average += index_finger.tip_position
                    valid_fingers += 1

                if(self.use_vertscroll): 
                    prev_finger = controller.frame(i+1).fingers.finger_type(Finger.TYPE_INDEX)[0]
                    if (prev_finger.is_valid and index_finger.is_valid):
                        diff = prev_finger.tip_position.y - index_finger.tip_position.y
                       # print diff
       
                        if ( math.fabs(diff) > self.SCROLL_THRESHOLD ):
                            self.action.scroll(math.copysign(1,-diff))

                elif index_finger.is_valid and index_finger.type == Leap.Finger.TYPE_INDEX:
                    roll = finger.direction.roll + self.roll_offset
                    if math.fabs(roll) > self.vert_scroll_limit:
                        self.action.scroll(self.vert_scroll_limit-roll)
                        print roll
                  
            average /= valid_fingers
            if not valid_fingers == 0:              
                self.action.mouse(average, index_finger)
            count = 0
              
        else:
            self.count += 1
开发者ID:rbaehr,项目名称:HoyaHacks,代码行数:74,代码来源:listener.py


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