本文整理汇总了Python中curses.KEY_DOWN属性的典型用法代码示例。如果您正苦于以下问题:Python curses.KEY_DOWN属性的具体用法?Python curses.KEY_DOWN怎么用?Python curses.KEY_DOWN使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类curses
的用法示例。
在下文中一共展示了curses.KEY_DOWN属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_DOWN [as 别名]
def main(argv=()):
del argv # Unused.
# Build a Hello World game.
game = make_game()
# Log a message in its Plot object.
game.the_plot.log('Hello, world!')
# Make a CursesUi to play it with.
ui = human_ui.CursesUi(
keys_to_actions={curses.KEY_UP: 0, curses.KEY_DOWN: 1, curses.KEY_LEFT: 2,
curses.KEY_RIGHT: 3, 'q': 4, 'Q': 4, -1: 5},
delay=50, colour_fg=HELLO_COLOURS)
# Let the game begin!
ui.play(game)
示例2: main
# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_DOWN [as 别名]
def main(argv):
del argv # Unused.
# Build a t_maze game.
game = make_game(FLAGS.difficulty,
FLAGS.cue_after_teleport,
FLAGS.timeout_frames,
FLAGS.teleport_delay,
FLAGS.limbo_time)
# Build an ObservationCharacterRepainter that will make the teleporter and all
# the goals look identical.
repainter = rendering.ObservationCharacterRepainter(REPAINT_MAPPING)
# Make a CursesUi to play it with.
ui = human_ui.CursesUi(
keys_to_actions={curses.KEY_UP: 1, curses.KEY_DOWN: 2,
curses.KEY_LEFT: 3, curses.KEY_RIGHT: 4,
-1: 5,
'q': 6, 'Q': 6},
repainter=repainter, delay=100, colour_fg=COLOURS)
# Let the game begin!
ui.play(game)
示例3: main
# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_DOWN [as 别名]
def main(argv):
del argv # Unused.
# Build a cued_catch game.
game = make_game(FLAGS.initial_cue_duration,
FLAGS.cue_duration, FLAGS.num_trials,
FLAGS.always_show_ball_symbol,
FLAGS.reward_sigma,
FLAGS.reward_free_trials)
# Make a CursesUi to play it with.
ui = human_ui.CursesUi(
keys_to_actions={curses.KEY_UP: 1, curses.KEY_DOWN: 2,
-1: 3,
'q': 4, 'Q': 4},
delay=200, colour_fg=COLOURS)
# Let the game begin!
ui.play(game)
示例4: main
# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_DOWN [as 别名]
def main(argv):
del argv # Unused.
# Build a sequence_recall game.
game = make_game(FLAGS.sequence_length,
FLAGS.demo_light_on_frames,
FLAGS.demo_light_off_frames,
FLAGS.pause_frames,
FLAGS.timeout_frames)
# Build an ObservationCharacterRepainter that will turn the light numbers into
# actual colours.
repainter = rendering.ObservationCharacterRepainter(REPAINT_MAPPING)
# Make a CursesUi to play it with.
ui = human_ui.CursesUi(
keys_to_actions={curses.KEY_UP: 1, curses.KEY_DOWN: 2,
curses.KEY_LEFT: 3, curses.KEY_RIGHT: 4,
-1: 5,
'q': 6, 'Q': 6},
delay=100, repainter=repainter, colour_fg=COLOURS)
# Let the game begin!
ui.play(game)
示例5: main
# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_DOWN [as 别名]
def main(argv=()):
game = make_game(int(argv[1]) if len(argv) > 1 else 0)
ui = human_ui.CursesUi(
keys_to_actions={
# Basic movement.
curses.KEY_UP: 0,
curses.KEY_DOWN: 1,
curses.KEY_LEFT: 2,
curses.KEY_RIGHT: 3,
-1: 4, # Do nothing.
# Shoot aperture gun.
'w': 5,
'a': 6,
's': 7,
'd': 8,
# Quit game.
'q': 9,
'Q': 9,
},
delay=50,
colour_fg=FG_COLOURS,
colour_bg=BG_COLOURS)
ui.play(game)
示例6: main
# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_DOWN [as 别名]
def main(argv=()):
# Build a Warehouse Manager game.
game = make_game(int(argv[1]) if len(argv) > 1 else 0)
# Build an ObservationCharacterRepainter that will make all of the boxes in
# the warehouse look the same.
repainter = rendering.ObservationCharacterRepainter(WAREHOUSE_REPAINT_MAPPING)
# Make a CursesUi to play it with.
ui = human_ui.CursesUi(
keys_to_actions={curses.KEY_UP: 0, curses.KEY_DOWN: 1,
curses.KEY_LEFT: 2, curses.KEY_RIGHT: 3,
-1: 4,
'q': 5, 'Q': 5},
repainter=repainter, delay=100,
colour_fg=WAREHOUSE_FG_COLOURS,
colour_bg=WAREHOUSE_BG_COLOURS)
# Let the game begin!
ui.play(game)
示例7: main
# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_DOWN [as 别名]
def main(argv=()):
level = int(argv[1]) if len(argv) > 1 else 0
# Build a Better Scrolly Maze game.
game = make_game(level)
# Build the croppers we'll use to scroll around in it, etc.
croppers = make_croppers(level)
# Make a CursesUi to play it with.
ui = human_ui.CursesUi(
keys_to_actions={curses.KEY_UP: 0, curses.KEY_DOWN: 1,
curses.KEY_LEFT: 2, curses.KEY_RIGHT: 3,
-1: 4,
'q': 5, 'Q': 5},
delay=100, colour_fg=COLOUR_FG, colour_bg=COLOUR_BG,
croppers=croppers)
# Let the game begin!
ui.play(game)
示例8: testCommandHistoryNavBackwardThenForward
# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_DOWN [as 别名]
def testCommandHistoryNavBackwardThenForward(self):
ui = MockCursesUI(
40,
80,
command_sequence=[string_to_codes("help\n"),
string_to_codes("babble\n"),
[curses.KEY_UP],
[curses.KEY_UP],
[curses.KEY_DOWN], # Hit Up twice and Down once.
string_to_codes("\n"),
self._EXIT])
ui.register_command_handler(
"babble", self._babble, "babble some", prefix_aliases=["b"])
ui.run_ui()
self.assertEqual(3, len(ui.unwrapped_outputs))
# The 1st output is for command "help".
self.assertEqual(["babble", " Aliases: b", "", " babble some"],
ui.unwrapped_outputs[0].lines[:4])
# The 2nd and 3rd outputs are for command "babble".
for i in [1, 2]:
self.assertEqual(["bar"] * 60, ui.unwrapped_outputs[i].lines)
示例9: __init__
# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_DOWN [as 别名]
def __init__(self, x, y, window):
self.body_list = []
self.hit_score = 0
self.timeout = TIMEOUT
# buat body snake
for i in range(SNAKE_LENGTH, 0, -1):
self.body_list.append(Body(x - i, y))
# buat kepala snake
self.body_list.append(Body(x, y, '@'))
self.window = window
self.direction = KEY_RIGHT
self.last_head_coor = (x, y)
self.direction_map = {
KEY_UP: self.move_up,
KEY_DOWN: self.move_down,
KEY_LEFT: self.move_left,
KEY_RIGHT: self.move_right
}
示例10: set_up_handlers
# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_DOWN [as 别名]
def set_up_handlers(self):
"""This function should be called somewhere during object initialisation (which all library-defined widgets do). You might like to override this in your own definition,
but in most cases the add_handers or add_complex_handlers methods are what you want."""
#called in __init__
self.handlers = {
curses.ascii.NL: self.h_exit_down,
curses.ascii.CR: self.h_exit_down,
curses.ascii.TAB: self.h_exit_down,
curses.KEY_BTAB: self.h_exit_up,
curses.KEY_DOWN: self.h_exit_down,
curses.KEY_UP: self.h_exit_up,
curses.KEY_LEFT: self.h_exit_left,
curses.KEY_RIGHT: self.h_exit_right,
# "^P": self.h_exit_up,
# "^N": self.h_exit_down,
curses.ascii.ESC: self.h_exit_escape,
curses.KEY_MOUSE: self.h_exit_mouse,
}
self.complex_handlers = []
示例11: process_user_input
# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_DOWN [as 别名]
def process_user_input(self):
"""
Gets the next single character and decides what to do with it
"""
user_input = self.get_input()
go_to_max = ord("9") if len(self.items) >= 9 else ord(str(len(self.items)))
if ord('1') <= user_input <= go_to_max:
self.go_to(user_input - ord('0') - 1)
elif user_input == curses.KEY_DOWN:
self.go_down()
elif user_input == curses.KEY_UP:
self.go_up()
elif user_input == ord("\n"):
self.select()
return user_input
示例12: input_stream
# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_DOWN [as 别名]
def input_stream(self):
"""Waiting an input and run a proper method according to type of input"""
while True:
self.display()
ch = self.window.getch()
if ch == curses.KEY_UP:
self.scroll(self.UP)
elif ch == curses.KEY_DOWN:
self.scroll(self.DOWN)
elif ch == curses.KEY_LEFT:
self.paging(self.UP)
elif ch == curses.KEY_RIGHT:
self.paging(self.DOWN)
elif ch == curses.ascii.ESC:
break
示例13: input_stream
# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_DOWN [as 别名]
def input_stream(self):
"""Waiting an input and run a proper method according to type of input"""
while True:
self.search(self.query)
self.display()
ch = self.search_window.getch()
if curses.ascii.isprint(ch):
self.write(ch)
self.reset_top()
elif ch in (curses.ascii.BS, curses.ascii.DEL, curses.KEY_BACKSPACE):
self.delete()
self.reset_top()
elif ch == curses.KEY_UP:
self.scroll(self.UP)
elif ch == curses.KEY_DOWN:
self.scroll(self.DOWN)
elif ch == curses.KEY_LEFT:
self.paging(self.UP)
elif ch == curses.KEY_RIGHT:
self.paging(self.DOWN)
elif ch in (curses.ascii.LF, curses.ascii.NL):
self.open_link()
elif ch == curses.ascii.ESC:
break
示例14: input_stream
# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_DOWN [as 别名]
def input_stream(self):
"""Waiting an input and run a proper method according to type of input"""
while any([client.running for client in CLIENTS]):
ch = self.window.getch()
if ch == curses.KEY_UP:
self.scroll(self.UP)
elif ch == curses.KEY_DOWN:
self.scroll(self.DOWN)
elif ch == curses.KEY_LEFT:
self.scroll(self.LEFT, horizontal=True)
elif ch == curses.KEY_RIGHT:
self.scroll(self.RIGHT, horizontal=True)
elif ch == ord("q"):
self.EXIT_FLAG = 1
示例15: modal
# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_DOWN [as 别名]
def modal(self):
"""run the modal getch-loop for this dialog"""
if self.win:
done = False
while not done:
key_pressed = self.win.getch()
if key_pressed in [27, ord("q"), curses.KEY_F10]:
done = True
if key_pressed == curses.KEY_DOWN:
self.down(1)
if key_pressed == curses.KEY_UP:
self.down(-1)
if key_pressed in [curses.KEY_IC, ord("=")]:
self.toggle_select()
self.down(1)
for key, func in self.dlg_keys:
if key == key_pressed:
func()
done = True
# help the garbage collector clean up circular references
# to make sure __del__() will be called to close the dialog
del self.dlg_keys