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


Python key.ESCAPE屬性代碼示例

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


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

示例1: on_key_press

# 需要導入模塊: from pyglet.window import key [as 別名]
# 或者: from pyglet.window.key import ESCAPE [as 別名]
def on_key_press(self, symbol, modifiers):
        if symbol == key._1:
            self.apply = not self.apply
            with self.shader:
                self.shader.uniformi("iApply", self.apply)

        if symbol == key._2:
            self.hyperbolic = not self.hyperbolic
            with self.shader:
                self.shader.uniformi("iHyperbolic", self.hyperbolic)

        if symbol == key._3:
            self.elliptic = not self.elliptic
            with self.shader:
                self.shader.uniformi("iElliptic", self.elliptic)

        if symbol == key.V and (modifiers & key.LCTRL):
            self.switch_video()

        if symbol == key.ENTER:
            self.save_screenshot()

        if symbol == key.ESCAPE:
            pyglet.app.exit() 
開發者ID:neozhaoliang,項目名稱:pywonderland,代碼行數:26,代碼來源:Mobius_in_H3space.py

示例2: on_key_press

# 需要導入模塊: from pyglet.window import key [as 別名]
# 或者: from pyglet.window.key import ESCAPE [as 別名]
def on_key_press(self, symbol, modifiers):
        """Called when the player presses a key. See pyglet docs for key
        mappings.

        Parameters
        ----------
        symbol : int
            Number representing the key that was pressed.
        modifiers : int
            Number representing any modifying keys that were pressed.
        config_data["controls"] : dict
            control map read by the configuration file
        """
        if symbol == key.ESCAPE:
            self.set_exclusive_mouse(False)
        else:
            self.gamestatemanager.peek().on_key_press(symbol, modifiers, self.config_data["controls"]) 
開發者ID:traverseda,項目名稱:pycraft,代碼行數:19,代碼來源:window.py

示例3: on_key_press

# 需要導入模塊: from pyglet.window import key [as 別名]
# 或者: from pyglet.window.key import ESCAPE [as 別名]
def on_key_press(self, symbol, modifiers):
        """Event handler for the Window.on_key_press event."""
        if symbol == key.ENTER:
            self.scene_manager.change_scene('GameScene')
        elif symbol == key.ESCAPE:
            self.window.set_exclusive_mouse(False)
            return pyglet.event.EVENT_HANDLED

        if symbol in (key._1, key._2, key._3):
            if symbol == key._1:
                self.scene_manager.save.save_slot = 1
            elif symbol == key._2:
                self.scene_manager.save.save_slot = 2
            elif symbol == key._3:
                self.scene_manager.save.save_slot = 3
            self._highlight_save_slot() 
開發者ID:XenonLab-Studio,項目名稱:TerraCraft,代碼行數:18,代碼來源:scenes.py

示例4: on_key_press

# 需要導入模塊: from pyglet.window import key [as 別名]
# 或者: from pyglet.window.key import ESCAPE [as 別名]
def on_key_press(self, symbol, modifiers):
        """
        Keyboard interface.
        """
        if symbol == key.ENTER:
            self.save_screenshot()

        if symbol == key.ESCAPE:
            pyglet.app.exit() 
開發者ID:neozhaoliang,項目名稱:pywonderland,代碼行數:11,代碼來源:example_wythoff_shader_animation.py

示例5: on_key_press

# 需要導入模塊: from pyglet.window import key [as 別名]
# 或者: from pyglet.window.key import ESCAPE [as 別名]
def on_key_press(self, symbol, modifiers):
        """Keyboard interface.
        """
        if symbol == key.ENTER:
            self.save_screenshot()

        if symbol == key.ESCAPE:
            pyglet.app.exit()

        if symbol == key.S and (modifiers & key.LCTRL):
            scene_file = load()
            self.shader = Shader(["./glsl/fractal3d.vert"], [scene_file])
            self.init_shader() 
開發者ID:neozhaoliang,項目名稱:pywonderland,代碼行數:15,代碼來源:fractal3d.py

示例6: on_key_press

# 需要導入模塊: from pyglet.window import key [as 別名]
# 或者: from pyglet.window.key import ESCAPE [as 別名]
def on_key_press(self, symbol, modifiers):
        """Keyboard interface.
        """
        if symbol == key.ENTER:
            self.save_screenshot()

        if symbol == key.ESCAPE:
            pyglet.app.exit() 
開發者ID:neozhaoliang,項目名稱:pywonderland,代碼行數:10,代碼來源:example_wythoff_shader_animation.py

示例7: on_key_press

# 需要導入模塊: from pyglet.window import key [as 別名]
# 或者: from pyglet.window.key import ESCAPE [as 別名]
def on_key_press(self, symbol, modifiers):
        if symbol == key.ENTER:
            self.save_screenshot()

        if symbol == key.ESCAPE:
            pyglet.app.exit() 
開發者ID:neozhaoliang,項目名稱:pywonderland,代碼行數:8,代碼來源:loxodrome.py

示例8: on_key_press

# 需要導入模塊: from pyglet.window import key [as 別名]
# 或者: from pyglet.window.key import ESCAPE [as 別名]
def on_key_press(symbol, modifiers):
    """
    This handler processes keyboard commands that
    control the simulation
    """

    if symbol == key.BACKSPACE or symbol == key.SLASH:
        print('RESET')
        env.reset()
        env.render('pyglet', view=view_mode)
        return

    if symbol == key.ESCAPE:
        env.close()
        sys.exit(0)

    if symbol == key.UP:
        step(env.actions.move_forward)
    elif symbol == key.DOWN:
        step(env.actions.move_back)

    elif symbol == key.LEFT:
        step(env.actions.turn_left)
    elif symbol == key.RIGHT:
        step(env.actions.turn_right)

    elif symbol == key.PAGEUP or symbol == key.P:
        step(env.actions.pickup)
    elif symbol == key.PAGEDOWN or symbol == key.D:
        step(env.actions.drop)

    elif symbol == key.ENTER:
        step(env.actions.done) 
開發者ID:maximecb,項目名稱:gym-miniworld,代碼行數:35,代碼來源:manual_control.py

示例9: on_key_press

# 需要導入模塊: from pyglet.window import key [as 別名]
# 或者: from pyglet.window.key import ESCAPE [as 別名]
def on_key_press(symbol, modifiers):
    if symbol == key.SPACE:
        balls.append(Ball())
    elif symbol == key.BACKSPACE:
        if balls:
            del balls[-1]
    elif symbol == key.ESCAPE:
        window.has_exit = True 
開發者ID:shrimpboyho,項目名稱:flappy-bird-py,代碼行數:10,代碼來源:noisy.py

示例10: on_key_press

# 需要導入模塊: from pyglet.window import key [as 別名]
# 或者: from pyglet.window.key import ESCAPE [as 別名]
def on_key_press(symbol, modifiers):
    # Overrides default Escape key behaviour
    if symbol == KEY_PAUSE and in_game:
        if not paused:
            pause_game()
        else:
            resume_game()
        return True
    elif symbol == key.ESCAPE:
        sys.exit()
    return pyglet.event.EVENT_HANDLED 
開發者ID:shrimpboyho,項目名稱:flappy-bird-py,代碼行數:13,代碼來源:astraea.py

示例11: on_key_press

# 需要導入模塊: from pyglet.window import key [as 別名]
# 或者: from pyglet.window.key import ESCAPE [as 別名]
def on_key_press(self, symbol, modifiers):
        if symbol == key.SPACE:
            self.on_play_pause()
        elif symbol == key.ESCAPE:
            self.dispatch_event('on_close') 
開發者ID:shrimpboyho,項目名稱:flappy-bird-py,代碼行數:7,代碼來源:media_player.py

示例12: on_key_press

# 需要導入模塊: from pyglet.window import key [as 別名]
# 或者: from pyglet.window.key import ESCAPE [as 別名]
def on_key_press(self, symbol, modifiers):
        names = [
            self.w.CURSOR_DEFAULT,
            self.w.CURSOR_CROSSHAIR,
            self.w.CURSOR_HAND,
            self.w.CURSOR_HELP,
            self.w.CURSOR_NO,
            self.w.CURSOR_SIZE,
            self.w.CURSOR_SIZE_UP,
            self.w.CURSOR_SIZE_UP_RIGHT,
            self.w.CURSOR_SIZE_RIGHT,
            self.w.CURSOR_SIZE_DOWN_RIGHT,
            self.w.CURSOR_SIZE_DOWN,
            self.w.CURSOR_SIZE_DOWN_LEFT,
            self.w.CURSOR_SIZE_LEFT,
            self.w.CURSOR_SIZE_UP_LEFT,
            self.w.CURSOR_SIZE_UP_DOWN,
            self.w.CURSOR_SIZE_LEFT_RIGHT,
            self.w.CURSOR_TEXT,
            self.w.CURSOR_WAIT,
            self.w.CURSOR_WAIT_ARROW,
        ]
        if symbol == key.ESCAPE:
            self.w.on_close()
        if symbol == key.RIGHT:
            self.i = (self.i + 1) % len(names)
        elif symbol == key.LEFT:
            self.i = (self.i - 1) % len(names)
        cursor = self.w.get_system_mouse_cursor(names[self.i])
        self.w.set_mouse_cursor(cursor)
        print 'Set cursor to "%s"' % names[self.i]
            
        return True 
開發者ID:shrimpboyho,項目名稱:flappy-bird-py,代碼行數:35,代碼來源:WINDOW_SET_MOUSE_SYSTEM_CURSOR.py

示例13: on_key_press

# 需要導入模塊: from pyglet.window import key [as 別名]
# 或者: from pyglet.window.key import ESCAPE [as 別名]
def on_key_press(self, symbol, modifiers):
        '''Default on_key_press handler.'''
        if symbol == key.ESCAPE and not (modifiers & ~(key.MOD_NUMLOCK |
                                                                            key.MOD_CAPSLOCK |
                                                                            key.MOD_SCROLLLOCK)):
            self.dispatch_event('on_close') 
開發者ID:shrimpboyho,項目名稱:flappy-bird-py,代碼行數:8,代碼來源:__init__.py

示例14: on_key_press

# 需要導入模塊: from pyglet.window import key [as 別名]
# 或者: from pyglet.window.key import ESCAPE [as 別名]
def on_key_press(self, symbol, modifiers):
        if symbol == key.ESCAPE:
            self.has_exit = True 
開發者ID:shrimpboyho,項目名稱:flappy-bird-py,代碼行數:5,代碼來源:event.py

示例15: on_key_press

# 需要導入模塊: from pyglet.window import key [as 別名]
# 或者: from pyglet.window.key import ESCAPE [as 別名]
def on_key_press(symbol, modifiers):
    # Overrides default Escape key behaviour
    if symbol == KEY_PAUSE and in_game:
        if not paused:
            pause_game()
        else:
            resume_game()
        return True
    elif symbol == key.ESCAPE:
        win.close()
    return pyglet.event.EVENT_HANDLED 
開發者ID:pyglet,項目名稱:pyglet,代碼行數:13,代碼來源:astraea.py


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