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


Python curses.KEY_RIGHT属性代码示例

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


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

示例1: main

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_RIGHT [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_RIGHT [as 别名]
def main(argv=()):
  del argv  # Unused.

  # Build an Apprehend game.
  game = make_game()

  # Build an ObservationCharacterRepainter that will make the player and the
  # ball look identical.
  repainter = rendering.ObservationCharacterRepainter(REPAINT_MAPPING)

  # Make a CursesUi to play it with.
  ui = human_ui.CursesUi(
      keys_to_actions={curses.KEY_LEFT: 0, curses.KEY_RIGHT: 1, -1: 2},
      repainter=repainter, delay=500,
      colour_fg=COLOURS)

  # Let the game begin!
  ui.play(game) 
开发者ID:deepmind,项目名称:pycolab,代码行数:20,代码来源:apprehend.py

示例3: main

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_RIGHT [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

示例4: main

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_RIGHT [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_RIGHT [as 别名]
def main(argv=()):
  del argv  # Unused.

  # Build an Extraterrestrial Marauders game.
  game = make_game()

  # Build an ObservationCharacterRepainter that will make laser bolts of the
  # same type all look identical.
  repainter = rendering.ObservationCharacterRepainter(LASER_REPAINT_MAPPING)

  # Make a CursesUi to play it with.
  ui = human_ui.CursesUi(
      keys_to_actions={curses.KEY_LEFT: 0, curses.KEY_RIGHT: 1,
                       ' ': 2,   # shoot
                       -1: 3,    # no-op
                       'q': 4},  # quit
      repainter=repainter, delay=300,
      colour_fg=COLOURS_FG, colour_bg=COLOURS_BG)

  # Let the game begin!
  ui.play(game) 
开发者ID:deepmind,项目名称:pycolab,代码行数:23,代码来源:extraterrestrial_marauders.py

示例6: main

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_RIGHT [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

示例7: __init__

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_RIGHT [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

示例8: test_cuf1_and_cub1_as_RIGHT_LEFT

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_RIGHT [as 别名]
def test_cuf1_and_cub1_as_RIGHT_LEFT(all_terms):
    "Test that cuf1 and cub1 are assigned KEY_RIGHT and KEY_LEFT."
    from blessed.keyboard import get_keyboard_sequences

    @as_subprocess
    def child(kind):
        term = TestTerminal(kind=kind, force_styling=True)
        keymap = get_keyboard_sequences(term)
        if term._cuf1:
            assert term._cuf1 in keymap
            assert keymap[term._cuf1] == term.KEY_RIGHT
        if term._cub1:
            assert term._cub1 in keymap
            if term._cub1 == '\b':
                assert keymap[term._cub1] == term.KEY_BACKSPACE
            else:
                assert keymap[term._cub1] == term.KEY_LEFT

    child(all_terms) 
开发者ID:QData,项目名称:deepWordBug,代码行数:21,代码来源:test_keyboard.py

示例9: _alternative_left_right

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_RIGHT [as 别名]
def _alternative_left_right(term):
    r"""
    Determine and return mapping of left and right arrow keys sequences.

    :arg blessed.Terminal term: :class:`~.Terminal` instance.
    :rtype: dict

    This function supports :func:`get_terminal_sequences` to discover
    the preferred input sequence for the left and right application keys.

    Return dict of sequences ``term._cuf1``, and ``term._cub1``,
    valued as ``KEY_RIGHT``, ``KEY_LEFT`` (when appropriate).  It is
    necessary to check the value of these sequences to ensure we do not
    use ``u' '`` and ``u'\b'`` for ``KEY_RIGHT`` and ``KEY_LEFT``,
    preferring their true application key sequence, instead.
    """
    keymap = dict()
    if term._cuf1 and term._cuf1 != u' ':
        keymap[term._cuf1] = curses.KEY_RIGHT
    if term._cub1 and term._cub1 != u'\b':
        keymap[term._cub1] = curses.KEY_LEFT
    return keymap 
开发者ID:QData,项目名称:deepWordBug,代码行数:24,代码来源:keyboard.py

示例10: _get_key_py33

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_RIGHT [as 别名]
def _get_key_py33(self):
        """Python 3.3+ implementation of get_key."""
        # pylint: disable=too-many-return-statements
        try:
            # Curses in Python 3.3 handles unicode via get_wch
            key = self.window.get_wch()
            if isinstance(key, int):
                if key == curses.KEY_BACKSPACE:
                    return "KEY_BACKSPACE"
                if key == curses.KEY_LEFT:
                    return "KEY_LEFT"
                if key == curses.KEY_RIGHT:
                    return "KEY_RIGHT"
                if key == curses.KEY_RESIZE:
                    return "KEY_RESIZE"
                return None
            return key
        except curses.error:
            return None
        except KeyboardInterrupt:
            raise 
开发者ID:cslarsen,项目名称:wpm,代码行数:23,代码来源:screen.py

示例11: set_up_handlers

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_RIGHT [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

示例12: input_stream

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_RIGHT [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 
开发者ID:mingrammer,项目名称:python-curses-scroll-example,代码行数:18,代码来源:tui.py

示例13: input_stream

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

示例14: input_stream

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

示例15: setUp

# 需要导入模块: import curses [as 别名]
# 或者: from curses import KEY_RIGHT [as 别名]
def setUp(self):
        self.mock_curses = mock.patch(
            "memory_analyzer.frontend.memanz_curses.curses"
        ).start()
        self.addCleanup(self.mock_curses.stop)
        self.mock_curses.LINES = 2
        self.mock_curses.COLS = 100
        self.mock_curses.KEY_DOWN = curses.KEY_DOWN
        self.mock_curses.KEY_UP = curses.KEY_UP
        self.mock_curses.KEY_PPAGE = curses.KEY_PPAGE
        self.mock_curses.KEY_NPAGE = curses.KEY_NPAGE
        self.mock_curses.KEY_RIGHT = curses.KEY_RIGHT
        self.mock_curses.KEY_LEFT = curses.KEY_LEFT
        self.statusbarstr = " | Navigate with arrows or wasd | Press 'q' to exit"
        self.pages = [["Page1", 10, 1024], ["Page2", 90, 100]]
        self.titles = ["Analysis of 1234", "Snapshot Differences"]
        self.win = memanz_curses.Window(self.mock_curses, self.pages, self.titles) 
开发者ID:facebookincubator,项目名称:memory-analyzer,代码行数:19,代码来源:test_curses.py


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