當前位置: 首頁>>代碼示例>>Python>>正文


Python key.MOD_CTRL屬性代碼示例

本文整理匯總了Python中pyglet.window.key.MOD_CTRL屬性的典型用法代碼示例。如果您正苦於以下問題:Python key.MOD_CTRL屬性的具體用法?Python key.MOD_CTRL怎麽用?Python key.MOD_CTRL使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在pyglet.window.key的用法示例。


在下文中一共展示了key.MOD_CTRL屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _get_modifiers

# 需要導入模塊: from pyglet.window import key [as 別名]
# 或者: from pyglet.window.key import MOD_CTRL [as 別名]
def _get_modifiers(self, key_lParam=0):
        modifiers = 0
        if _user32.GetKeyState(VK_SHIFT) & 0xff00:
            modifiers |= key.MOD_SHIFT
        if _user32.GetKeyState(VK_CONTROL) & 0xff00:
            modifiers |= key.MOD_CTRL
        if _user32.GetKeyState(VK_LWIN) & 0xff00:
            modifiers |= key.MOD_WINDOWS
        if _user32.GetKeyState(VK_CAPITAL) & 0x00ff:    # toggle
            modifiers |= key.MOD_CAPSLOCK
        if _user32.GetKeyState(VK_NUMLOCK) & 0x00ff:    # toggle
            modifiers |= key.MOD_NUMLOCK
        if _user32.GetKeyState(VK_SCROLL) & 0x00ff:    # toggle
            modifiers |= key.MOD_SCROLLLOCK
        if key_lParam:
            if key_lParam & (1 << 29):
                modifiers |= key.MOD_ALT
        elif _user32.GetKeyState(VK_MENU) < 0:
            modifiers |= key.MOD_ALT
        return modifiers 
開發者ID:shrimpboyho,項目名稱:flappy-bird-py,代碼行數:22,代碼來源:__init__.py

示例2: _translate_modifiers

# 需要導入模塊: from pyglet.window import key [as 別名]
# 或者: from pyglet.window.key import MOD_CTRL [as 別名]
def _translate_modifiers(state):
        modifiers = 0
        if state & xlib.ShiftMask:
            modifiers |= key.MOD_SHIFT
        if state & xlib.ControlMask:
            modifiers |= key.MOD_CTRL
        if state & xlib.LockMask:
            modifiers |= key.MOD_CAPSLOCK
        if state & xlib.Mod1Mask:
            modifiers |= key.MOD_ALT
        if state & xlib.Mod2Mask:
            modifiers |= key.MOD_NUMLOCK
        if state & xlib.Mod4Mask:
            modifiers |= key.MOD_WINDOWS
        if state & xlib.Mod5Mask:
            modifiers |= key.MOD_SCROLLLOCK
        return modifiers

    # Event handlers 
開發者ID:shrimpboyho,項目名稱:flappy-bird-py,代碼行數:21,代碼來源:__init__.py

示例3: on_key_press

# 需要導入模塊: from pyglet.window import key [as 別名]
# 或者: from pyglet.window.key import MOD_CTRL [as 別名]
def on_key_press(self, symbol, modifiers):
        fullscreen = not modifiers & key.MOD_CTRL
        doing = fullscreen and 'Setting' or 'Restoring from'
        if symbol == key._0:
            print('%s default size' % doing)
            self.w.set_fullscreen(fullscreen)
            return
        elif symbol == key._1:
            width, height = 320, 200
        elif symbol == key._2:
            width, height = 640, 480
        elif symbol == key._3:
            width, height = 800, 600
        elif symbol == key._4:
            width, height = 1024, 768
        elif symbol == key._5:
            width, height = 1280, 800 # 16:10
        elif symbol == key._6:
            width, height = 1280, 1024
        else:
            return
        print('%s width=%d, height=%d' % (doing, width, height))
        self.w.set_fullscreen(fullscreen, width=width, height=height) 
開發者ID:pyglet,項目名稱:pyglet,代碼行數:25,代碼來源:test_window_fullscreen.py

示例4: _update_question

# 需要導入模塊: from pyglet.window import key [as 別名]
# 或者: from pyglet.window.key import MOD_CTRL [as 別名]
def _update_question(self):
        modifiers = []
        if self.chosen_modifiers & key.MOD_SHIFT:
            modifiers.append('<Shift>')
        if self.chosen_modifiers & key.MOD_ALT:
            modifiers.append('<Alt/Option>')
        if self.chosen_modifiers & key.MOD_CTRL:
            modifiers.append('<Ctrl>')

        self.question = """Please press and release the following combination of keys.
Only use <Shift> if explicitly asked to do so.

{} {}


Press Esc if test does not pass.""".format(' '.join(modifiers), key.symbol_string(self.chosen_symbol))
        self._render_question() 
開發者ID:pyglet,項目名稱:pyglet,代碼行數:19,代碼來源:test_window_events.py

示例5: getModifiers

# 需要導入模塊: from pyglet.window import key [as 別名]
# 或者: from pyglet.window.key import MOD_CTRL [as 別名]
def getModifiers(nsevent):
    modifiers = 0
    modifierFlags = nsevent.modifierFlags()
    if modifierFlags & cocoapy.NSAlphaShiftKeyMask:
        modifiers |= key.MOD_CAPSLOCK
    if modifierFlags & cocoapy.NSShiftKeyMask:
        modifiers |= key.MOD_SHIFT
    if modifierFlags & cocoapy.NSControlKeyMask:
        modifiers |= key.MOD_CTRL
    if modifierFlags & cocoapy.NSAlternateKeyMask:
        modifiers |= key.MOD_ALT
        modifiers |= key.MOD_OPTION
    if modifierFlags & cocoapy.NSCommandKeyMask:
        modifiers |= key.MOD_COMMAND
    if modifierFlags & cocoapy.NSFunctionKeyMask:
        modifiers |= key.MOD_FUNCTION
    return modifiers 
開發者ID:pyglet,項目名稱:pyglet,代碼行數:19,代碼來源:pyglet_view.py

示例6: modifiers_string

# 需要導入模塊: from pyglet.window import key [as 別名]
# 或者: from pyglet.window.key import MOD_CTRL [as 別名]
def modifiers_string(modifiers):
    '''Return a string describing a set of modifiers.

    Example::

        >>> modifiers_string(MOD_SHIFT | MOD_CTRL)
        'MOD_SHIFT|MOD_CTRL'

    :Parameters:
        `modifiers` : int
            Bitwise combination of modifier constants.

    :rtype: str
    '''
    mod_names = []
    if modifiers & MOD_SHIFT:
        mod_names.append('MOD_SHIFT')
    if modifiers & MOD_CTRL:
        mod_names.append('MOD_CTRL')
    if modifiers & MOD_ALT:
        mod_names.append('MOD_ALT')
    if modifiers & MOD_CAPSLOCK:
        mod_names.append('MOD_CAPSLOCK')
    if modifiers & MOD_NUMLOCK:
        mod_names.append('MOD_NUMLOCK')
    if modifiers & MOD_SCROLLLOCK:
        mod_names.append('MOD_SCROLLLOCK')
    if modifiers & MOD_COMMAND:
        mod_names.append('MOD_COMMAND')
    if modifiers & MOD_OPTION:
        mod_names.append('MOD_OPTION')
    if modifiers & MOD_FUNCTION:
        mod_names.append('MOD_FUNCTION')
    return '|'.join(mod_names) 
開發者ID:openai,項目名稱:universe,代碼行數:36,代碼來源:key.py

示例7: _on_text_input

# 需要導入模塊: from pyglet.window import key [as 別名]
# 或者: from pyglet.window.key import MOD_CTRL [as 別名]
def _on_text_input(self, next_handler, ev, data):
        size = c_uint32()
        carbon.GetEventParameter(ev, kEventParamTextInputSendText,
            typeUTF8Text, c_void_p(), 0, byref(size), c_void_p())
        text = create_string_buffer(size.value)
        carbon.GetEventParameter(ev, kEventParamTextInputSendText,
            typeUTF8Text, c_void_p(), size.value, c_void_p(), byref(text))
        text = text.value.decode('utf8')

        raw_event = EventRef()
        carbon.GetEventParameter(ev, kEventParamTextInputSendKeyboardEvent,
            typeEventRef, c_void_p(), sizeof(raw_event), c_void_p(),
            byref(raw_event))
        symbol, modifiers = self._get_symbol_and_modifiers(raw_event)

        motion_modifiers = modifiers & \
            (key.MOD_COMMAND | key.MOD_CTRL | key.MOD_OPTION)
        if (symbol, motion_modifiers) in _motion_map:
            motion = _motion_map[symbol, motion_modifiers]
            if modifiers & key.MOD_SHIFT:
                self.dispatch_event('on_text_motion_select', motion)
            else:
                self.dispatch_event('on_text_motion', motion)
        elif ((unicodedata.category(text[0]) != 'Cc' or text == u'\r') and
            not (modifiers & key.MOD_COMMAND)):
            self.dispatch_event('on_text', text)
        return noErr 
開發者ID:shrimpboyho,項目名稱:flappy-bird-py,代碼行數:29,代碼來源:__init__.py

示例8: _map_modifiers

# 需要導入模塊: from pyglet.window import key [as 別名]
# 或者: from pyglet.window.key import MOD_CTRL [as 別名]
def _map_modifiers(modifiers):
        mapped_modifiers = 0
        if modifiers & (shiftKey | rightShiftKey):
            mapped_modifiers |= key.MOD_SHIFT
        if modifiers & (controlKey | rightControlKey):
            mapped_modifiers |= key.MOD_CTRL
        if modifiers & (optionKey | rightOptionKey):
            mapped_modifiers |= key.MOD_OPTION
        if modifiers & alphaLock:
            mapped_modifiers |= key.MOD_CAPSLOCK
        if modifiers & cmdKey:
            mapped_modifiers |= key.MOD_COMMAND

        return mapped_modifiers 
開發者ID:shrimpboyho,項目名稱:flappy-bird-py,代碼行數:16,代碼來源:__init__.py

示例9: modifiers_string

# 需要導入模塊: from pyglet.window import key [as 別名]
# 或者: from pyglet.window.key import MOD_CTRL [as 別名]
def modifiers_string(modifiers):
    '''Return a string describing a set of modifiers.

    Example::

        >>> modifiers_string(MOD_SHIFT | MOD_CTRL)
        'MOD_SHIFT|MOD_CTRL'

    :Parameters:
        `modifiers` : int
            Bitwise combination of modifier constants.

    :rtype: str
    '''
    mod_names = []
    if modifiers & MOD_SHIFT:
        mod_names.append('MOD_SHIFT')
    if modifiers & MOD_CTRL:
        mod_names.append('MOD_CTRL')
    if modifiers & MOD_ALT:
        mod_names.append('MOD_ALT')
    if modifiers & MOD_CAPSLOCK:
        mod_names.append('MOD_CAPSLOCK')
    if modifiers & MOD_NUMLOCK:
        mod_names.append('MOD_NUMLOCK')
    if modifiers & MOD_SCROLLLOCK:
        mod_names.append('MOD_SCROLLLOCK')
    if modifiers & MOD_COMMAND:
        mod_names.append('MOD_COMMAND')
    if modifiers & MOD_OPTION:
        mod_names.append('MOD_OPTION')
    return '|'.join(mod_names) 
開發者ID:shrimpboyho,項目名稱:flappy-bird-py,代碼行數:34,代碼來源:key.py

示例10: _event_text_motion

# 需要導入模塊: from pyglet.window import key [as 別名]
# 或者: from pyglet.window.key import MOD_CTRL [as 別名]
def _event_text_motion(self, symbol, modifiers):
        if modifiers & key.MOD_ALT:
            return None
        ctrl = modifiers & key.MOD_CTRL != 0
        return _motion_map.get((symbol, ctrl), None) 
開發者ID:shrimpboyho,項目名稱:flappy-bird-py,代碼行數:7,代碼來源:__init__.py

示例11: on_mouse_press

# 需要導入模塊: from pyglet.window import key [as 別名]
# 或者: from pyglet.window.key import MOD_CTRL [as 別名]
def on_mouse_press(self, x, y, button, modifiers):
        if (button == mouse.RIGHT) or \
                ((button == mouse.LEFT) and (modifiers & key.MOD_CTRL)):
            block, previous = self.player.hit(self.world.area.blocks, left=False)
            # ON OSX, control + left click = right click.
            if block and self.player.current_item:
                self.world.add_block(previous, get_block(self.player.get_block()))

        elif button == mouse.LEFT:
            block = self.player.hit(self.world.area.blocks)[0]
            if block:
                texture = self.world.area.get_block(block)
                if texture.hit_and_destroy():
                    self.world.remove_block(block) 
開發者ID:traverseda,項目名稱:pycraft,代碼行數:16,代碼來源:gs_running.py

示例12: _select_next_key

# 需要導入模塊: from pyglet.window import key [as 別名]
# 或者: from pyglet.window.key import MOD_CTRL [as 別名]
def _select_next_key(self):
        self.chosen_symbol = random.choice(self.keys)

        # Little trick, Ctrl, Alt and Shift are lowest modifier values, so everything between 0 and
        # the full combination is a permutation of these three.
        max_modifiers = key.MOD_SHIFT | key.MOD_ALT | key.MOD_CTRL
        # Give a little more weight to key without modifiers
        self.chosen_modifiers = max(0, random.randint(-2, max_modifiers))

        self._update_question() 
開發者ID:pyglet,項目名稱:pyglet,代碼行數:12,代碼來源:test_window_events.py

示例13: _get_modifier_for_key

# 需要導入模塊: from pyglet.window import key [as 別名]
# 或者: from pyglet.window.key import MOD_CTRL [as 別名]
def _get_modifier_for_key(self, symbol):
        if symbol in self.mod_shift_keys:
            return key.MOD_SHIFT
        elif symbol in self.mod_alt_keys:
            return key.MOD_ALT
        elif symbol in self.mod_ctrl_keys:
            return key.MOD_CTRL
        elif symbol in self.mod_option_keys:
            return key.MOD_OPTION
        elif symbol in self.mod_meta_keys:
            return self.mod_meta
        else:
            return 0 
開發者ID:pyglet,項目名稱:pyglet,代碼行數:15,代碼來源:test_window_events.py

示例14: _event_text_motion

# 需要導入模塊: from pyglet.window import key [as 別名]
# 或者: from pyglet.window.key import MOD_CTRL [as 別名]
def _event_text_motion(symbol, modifiers):
        if modifiers & key.MOD_ALT:
            return None
        ctrl = modifiers & key.MOD_CTRL != 0
        return _motion_map.get((symbol, ctrl), None) 
開發者ID:pyglet,項目名稱:pyglet,代碼行數:7,代碼來源:__init__.py

示例15: modifiers_string

# 需要導入模塊: from pyglet.window import key [as 別名]
# 或者: from pyglet.window.key import MOD_CTRL [as 別名]
def modifiers_string(modifiers):
    """Return a string describing a set of modifiers.

    Example::

        >>> modifiers_string(MOD_SHIFT | MOD_CTRL)
        'MOD_SHIFT|MOD_CTRL'

    :Parameters:
        `modifiers` : int
            Bitwise combination of modifier constants.

    :rtype: str
    """
    mod_names = []
    if modifiers & MOD_SHIFT:
        mod_names.append('MOD_SHIFT')
    if modifiers & MOD_CTRL:
        mod_names.append('MOD_CTRL')
    if modifiers & MOD_ALT:
        mod_names.append('MOD_ALT')
    if modifiers & MOD_CAPSLOCK:
        mod_names.append('MOD_CAPSLOCK')
    if modifiers & MOD_NUMLOCK:
        mod_names.append('MOD_NUMLOCK')
    if modifiers & MOD_SCROLLLOCK:
        mod_names.append('MOD_SCROLLLOCK')
    if modifiers & MOD_COMMAND:
        mod_names.append('MOD_COMMAND')
    if modifiers & MOD_OPTION:
        mod_names.append('MOD_OPTION')
    if modifiers & MOD_FUNCTION:
        mod_names.append('MOD_FUNCTION')
    return '|'.join(mod_names) 
開發者ID:pyglet,項目名稱:pyglet,代碼行數:36,代碼來源:key.py


注:本文中的pyglet.window.key.MOD_CTRL屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。