本文整理汇总了Python中pyglet.window.key.TAB属性的典型用法代码示例。如果您正苦于以下问题:Python key.TAB属性的具体用法?Python key.TAB怎么用?Python key.TAB使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类pyglet.window.key
的用法示例。
在下文中一共展示了key.TAB属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_key_press
# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import TAB [as 别名]
def on_key_press(self, symbol, modifiers):
super(TestWindow, self).on_key_press(symbol, modifiers)
if symbol == key.TAB:
self.caret.on_text('\t')
示例2: on_key_press
# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import TAB [as 别名]
def on_key_press(self, symbol, modifiers):
"""Event handler for the Window.on_key_press event.
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.
"""
if symbol == key.W:
self.strafe[0] -= 1
elif symbol == key.S:
self.strafe[0] += 1
elif symbol == key.A:
self.strafe[1] -= 1
elif symbol == key.D:
self.strafe[1] += 1
elif symbol == key.SPACE:
if self.flying:
# Reduces vertical flying speed
# 0.1 positive value that allows vertical flight up.
self.dy = 0.1 * JUMP_SPEED
elif self.dy == 0:
self.dy = JUMP_SPEED
self.audio.play(self.jump_sfx)
elif symbol == key.LCTRL:
self.running = True
elif symbol == key.LSHIFT:
if self.flying:
# Reduces vertical flying speed
# -0.1 negative value that allows vertical flight down.
self.dy = -0.1 * JUMP_SPEED
elif self.dy == 0:
self.dy = JUMP_SPEED
elif symbol == key.ESCAPE:
self.set_exclusive_mouse(False)
return pyglet.event.EVENT_HANDLED
elif symbol == key.TAB:
self.flying = not self.flying
elif symbol == key.F1:
self.scene_manager.change_scene("HelpScene")
elif symbol == key.F2:
self.toggleGui = not self.toggleGui
elif symbol == key.F3:
self.toggleLabel = not self.toggleLabel
elif symbol == key.F5:
self.scene_manager.save.save_world(self.model)
elif symbol == key.F12:
pyglet.image.get_buffer_manager().get_color_buffer().save('screenshot.png')
elif symbol in self.num_keys:
index = (symbol - self.num_keys[0]) % len(self.inventory)
self.block = self.inventory[index]
elif symbol == key.ENTER:
self.scene_manager.change_scene('MenuScene')