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


Python Keyboard.collide_point方法代码示例

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


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

示例1: IcarusTouchWidget

# 需要导入模块: from keyboard import Keyboard [as 别名]
# 或者: from keyboard.Keyboard import collide_point [as 别名]
class IcarusTouchWidget(Widget):
    app = ObjectProperty(None)
    float_layout = ObjectProperty(None)
    pitch_lock_button = ObjectProperty(None)
    y_axis_volume_button = ObjectProperty(None)
    setting_button = ObjectProperty(None)
    look_button = ObjectProperty(None)
    feedback_wall = ObjectProperty(None)
    scale_keywidth_touch_positions = {}
    version = StringProperty(VERSION)
    
    
    '''
    ####################################
    ##
    ##   Class Initialisation
    ##
    ####################################
    '''
    def __init__(self, **kwargs):
        super(IcarusTouchWidget, self).__init__(**kwargs) # don't know if this is necessary?
        
        # add background image (and add it in the BACKGROUND! --> index modification)
        self.background = Background(source=self.app.config.get('Graphics', 'Background'))
        self.float_layout.add_widget(self.background, index=len(self.float_layout.children))
        
        # add feedback wall image
        self.feedback_wall = Feedback(
            source='images/feedbackwall.png',
            transparency=0)
        self.float_layout.add_widget(self.feedback_wall)
        
        # add the keyboard itself
        my_key_width = KEY_WIDTH
        self.keyboard = Keyboard(
            source=self.app.config.get('Graphics', 'Keyboard'),
            pos=(-540, 230), # 366
            size=(12*5*my_key_width, 468), # optimization for small screens (e.g. smartphones): 468 if self.get_parent_window().height > (468 + self.get_parent_window().height * 0.3) else self.get_parent_window().height * 0.7
            border_width=BORDER_WIDTH,
            key_width=my_key_width)
        self.add_widget(self.keyboard)
        
        # initialize the midi device
        pygame.midi.init()
        self.set_midi_device()
        
        # initialize the settings_panel (I'm doing this here, otherwise opening it in real-time takes ages...)
        self.my_settings_panel = MySettingsPanel()
    
    
    '''
    ####################################
    ##
    ##   On Touch Down
    ##
    ####################################
    '''
    def on_touch_down(self, touch):
        ud = touch.ud
        
        # find out the touchs "function":  
        if self.my_settings_panel.is_open == True:
            # if the settingspanel is opened, it has total focus!
            # so if the user clicked on one of the two panels, don't dispatch the touch here but feed it to the panel
            if self.my_settings_panel.keyboard_scroll_view_box.collide_point(*touch.pos) or \
                self.my_settings_panel.background_scroll_view_grid.collide_point(*touch.pos):
                ud['settingspanel'] = True
                return super(IcarusTouchWidget, self).on_touch_down(touch)
            else:
                # user has clicked aside - he wants to quit the settings.
                self.close_my_settings_panel()
                return True
            
        elif self.keyboard.collide_point(*touch.pos):
            # if the user touched on the keyboard, feed the touch to the keyboard.
            return super(IcarusTouchWidget, self).on_touch_down(touch)
        
        elif self.pitch_lock_button.collide_point(*touch.pos) or \
            self.y_axis_volume_button.collide_point(*touch.pos) or \
            self.look_button.collide_point(*touch.pos) or \
            self.settings_button.collide_point(*touch.pos):
            # if the user touched one of the buttons, feed the touch to the buttons
            self.create_circle(touch)
            return super(IcarusTouchWidget, self).on_touch_down(touch)
        
        ##########################
        # X-Axis Key width scaling
        ##########################
        
        '''
        # if it wasn't a button nor a key touch nor a settings touch, its a scroll touch.
        for search_touch in EventLoop.touches[:]:
            # but if there is already another touch in scroll mode (and not already in 'scale' mode), maybe the desired action is 'scale' not 'scroll'
            if 'scroll' in search_touch.ud and not self.scale_keywidth_touch_positions:
                # remember their actual positions
                self.scale_keywidth_touch_positions = {'initial_first': search_touch.x, 'initial_second': touch.x, 'first_touch': search_touch, 'second_touch': touch}
                print 'multiple saving position data'
        '''
        
        # assign the scroll-tag not until here. Thus we just get the other existing scroll-touches in the search-routine above.
#.........这里部分代码省略.........
开发者ID:ammzen,项目名称:IcarusTouch,代码行数:103,代码来源:main.py


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