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


Python curses.KEY_UP属性代码示例

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


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

示例1: main

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_UP [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) 
开发者ID:deepmind,项目名称:pycolab,代码行数:19,代码来源:hello_world.py

示例2: main

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_UP [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) 
开发者ID:deepmind,项目名称:pycolab,代码行数:26,代码来源:t_maze.py

示例3: main

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_UP [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) 
开发者ID:deepmind,项目名称:pycolab,代码行数:21,代码来源:cued_catch.py

示例4: main

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_UP [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) 
开发者ID:deepmind,项目名称:pycolab,代码行数:26,代码来源:sequence_recall.py

示例5: main

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_UP [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) 
开发者ID:deepmind,项目名称:pycolab,代码行数:27,代码来源:aperture.py

示例6: main

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_UP [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) 
开发者ID:deepmind,项目名称:pycolab,代码行数:22,代码来源:warehouse_manager.py

示例7: main

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_UP [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) 
开发者ID:deepmind,项目名称:pycolab,代码行数:21,代码来源:better_scrolly_maze.py

示例8: testCommandHistoryNavBackwardOnce

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_UP [as 别名]
def testCommandHistoryNavBackwardOnce(self):
    ui = MockCursesUI(
        40,
        80,
        command_sequence=[string_to_codes("help\n"),
                          [curses.KEY_UP],  # Hit Up and Enter.
                          string_to_codes("\n"),
                          self._EXIT])

    ui.register_command_handler(
        "babble", self._babble, "babble some", prefix_aliases=["b"])
    ui.run_ui()

    self.assertEqual(2, len(ui.unwrapped_outputs))

    for i in [0, 1]:
      self.assertEqual(["babble", "  Aliases: b", "", "  babble some"],
                       ui.unwrapped_outputs[i].lines[:4]) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:20,代码来源:curses_ui_test.py

示例9: testCommandHistoryNavBackwardTwice

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_UP [as 别名]
def testCommandHistoryNavBackwardTwice(self):
    ui = MockCursesUI(
        40,
        80,
        command_sequence=[string_to_codes("help\n"),
                          string_to_codes("babble\n"),
                          [curses.KEY_UP],
                          [curses.KEY_UP],  # Hit Up twice and Enter.
                          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 and 3rd outputs are for command "help".
    for i in [0, 2]:
      self.assertEqual(["babble", "  Aliases: b", "", "  babble some"],
                       ui.unwrapped_outputs[i].lines[:4])

    # The 2nd output is for command "babble".
    self.assertEqual(["bar"] * 60, ui.unwrapped_outputs[1].lines) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:26,代码来源:curses_ui_test.py

示例10: testCommandHistoryNavBackwardOverLimit

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_UP [as 别名]
def testCommandHistoryNavBackwardOverLimit(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_UP],  # Hit Up three times and Enter.
                          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 and 3rd outputs are for command "help".
    for i in [0, 2]:
      self.assertEqual(["babble", "  Aliases: b", "", "  babble some"],
                       ui.unwrapped_outputs[i].lines[:4])

    # The 2nd output is for command "babble".
    self.assertEqual(["bar"] * 60, ui.unwrapped_outputs[1].lines) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:27,代码来源:curses_ui_test.py

示例11: testCommandHistoryNavBackwardThenForward

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_UP [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) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:27,代码来源:curses_ui_test.py

示例12: testCommandHistoryPrefixNavBackwardOnce

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_UP [as 别名]
def testCommandHistoryPrefixNavBackwardOnce(self):
    ui = MockCursesUI(
        40,
        80,
        command_sequence=[
            string_to_codes("babble -n 1\n"),
            string_to_codes("babble -n 10\n"),
            string_to_codes("help\n"),
            string_to_codes("b") + [curses.KEY_UP],  # Navigate with prefix.
            string_to_codes("\n"),
            self._EXIT
        ])

    ui.register_command_handler(
        "babble", self._babble, "babble some", prefix_aliases=["b"])
    ui.run_ui()

    self.assertEqual(["bar"], ui.unwrapped_outputs[0].lines)
    self.assertEqual(["bar"] * 10, ui.unwrapped_outputs[1].lines)
    self.assertEqual(["babble", "  Aliases: b", "", "  babble some"],
                     ui.unwrapped_outputs[2].lines[:4])
    self.assertEqual(["bar"] * 10, ui.unwrapped_outputs[3].lines) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:24,代码来源:curses_ui_test.py

示例13: __init__

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_UP [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
        } 
开发者ID:dhamarmulia,项目名称:dm-snake,代码行数:20,代码来源:main.py

示例14: set_up_handlers

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_UP [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 = [] 
开发者ID:hexway,项目名称:apple_bleee,代码行数:22,代码来源:wgwidget.py

示例15: process_user_input

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_UP [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 
开发者ID:pmbarrett314,项目名称:curses-menu,代码行数:20,代码来源:curses_menu.py


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