當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。