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


Python curses.wrapper方法代码示例

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


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

示例1: initscr

# 需要导入模块: import curses [as 别名]
# 或者: from curses import wrapper [as 别名]
def initscr():
    import _curses, curses
    # we call setupterm() here because it raises an error
    # instead of calling exit() in error cases.
    setupterm(term=_os.environ.get("TERM", "unknown"),
              fd=_sys.__stdout__.fileno())
    stdscr = _curses.initscr()
    for key, value in _curses.__dict__.items():
        if key[0:4] == 'ACS_' or key in ('LINES', 'COLS'):
            setattr(curses, key, value)

    return stdscr

# This is a similar wrapper for start_color(), which adds the COLORS and
# COLOR_PAIRS variables which are only available after start_color() is
# called. 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,代码来源:__init__.py

示例2: main

# 需要导入模块: import curses [as 别名]
# 或者: from curses import wrapper [as 别名]
def main():
        """
        If a project has a Curses driver, the section "main" in the section
        "run" must be "bibliopixel.drivers.curses.Curses.main".

        """
        if not _curses:
            # https://stackoverflow.com/a/1325587/43839
            if os.name == 'nt':
                raise ValueError('curses is not supported under Windows')
            raise ValueError('Your platform does not support curses.')
        try:
            driver = next(iter(Curses.DRIVERS))
        except:
            raise ValueError('No Curses driver in project')

        _curses.wrapper(driver.run_in_curses) 
开发者ID:ManiacalLabs,项目名称:BiblioPixel,代码行数:19,代码来源:curses.py

示例3: wrapper_basic

# 需要导入模块: import curses [as 别名]
# 或者: from curses import wrapper [as 别名]
def wrapper_basic(call_function):
    #set the locale properly
    locale.setlocale(locale.LC_ALL, '')
    return curses.wrapper(call_function)

#def wrapper(call_function):
#   locale.setlocale(locale.LC_ALL, '')
#   screen = curses.initscr()
#   curses.noecho()
#   curses.cbreak()
#   
#   return_code = call_function(screen)
#   
#   curses.nocbreak()
#   curses.echo()
#   curses.endwin() 
开发者ID:hexway,项目名称:apple_bleee,代码行数:18,代码来源:npyssafewrapper.py

示例4: main

# 需要导入模块: import curses [as 别名]
# 或者: from curses import wrapper [as 别名]
def main():
    args = parse_args()
    log.info('Requesting remote shell from {}', args.hostname)
    with PenguinDomeServerPeer(
            'server', local_port=get_setting('local_port'),
            logger=log, client_hostname=args.hostname) as remote, \
            TerminalPeer() as terminal:
        host = args.hostname
        script = '#!/bin/bash\npython client/endpoints/shell.py {}\n'.format(
            remote.pipe_id)
        patch_hosts('client/commands/shell-{}'.format(remote.pipe_id),
                    patch_content=script.encode('utf8'),
                    hosts=host)
        broker = InteractionBroker(terminal, remote, poll_interval=0.2)
        print('Waiting for client to connect (once connected, use "~." to '
              'disconnect)...')
        remote.poll()
        curses.wrapper(interact, broker) 
开发者ID:quantopian,项目名称:PenguinDome,代码行数:20,代码来源:client_shell.py

示例5: run_ci

# 需要导入模块: import curses [as 别名]
# 或者: from curses import wrapper [as 别名]
def run_ci():
    locale.setlocale(locale.LC_ALL, '')
    try:
        # Reduce the delay waiting for escape sequences.
        os.environ.setdefault('ESCDELAY', '1')
        curses.wrapper(wrapped_ci)
    finally:
        app.log.flush()
        app.log.writeToFile('~/.ci_edit/recentLog')
        # Disable Bracketed Paste Mode.
        sys.stdout.write('\033[?2004l')
        # Disable mouse tracking in xterm.
        sys.stdout.write('\033[?1002;l')
        sys.stdout.flush()
    if userConsoleMessage:
        fullPath = app.buffer_file.expandFullPath(
            '~/.ci_edit/userConsoleMessage')
        with io.open(fullPath, 'w+') as f:
            f.write(userConsoleMessage)
        sys.stdout.write(userConsoleMessage + '\n')
        sys.stdout.flush() 
开发者ID:google,项目名称:ci_edit,代码行数:23,代码来源:ci_program.py

示例6: main

# 需要导入模块: import curses [as 别名]
# 或者: from curses import wrapper [as 别名]
def main(argv):
    if len(argv) > 1:
        if argv[1] == 'slave':
            display = Display()
            curses.wrapper(display.show)
            return 1

    command = [
        sys.executable,
        os.path.realpath(__file__),
        'slave',
    ]
    while True:
        return_code = subprocess.call(command)
        if return_code != 1:
            break

    return 0 
开发者ID:ayeowch,项目名称:bitnodes-hardware,代码行数:20,代码来源:lcd.py

示例7: start

# 需要导入模块: import curses [as 别名]
# 或者: from curses import wrapper [as 别名]
def start():
	curses.wrapper(main) 
开发者ID:Jugran,项目名称:lyrics-in-terminal,代码行数:4,代码来源:lyrics_in_terminal.py

示例8: main

# 需要导入模块: import curses [as 别名]
# 或者: from curses import wrapper [as 别名]
def main():
    username = ''
    password = ''
    baidu_api = BaiduFmAPI(username, password)
    baidu_cli = BaiduFmCli(baidu_api)
    curses.wrapper(baidu_cli.setup) 
开发者ID:tdoly,项目名称:baidufm-py,代码行数:8,代码来源:baidufm.py

示例9: main

# 需要导入模块: import curses [as 别名]
# 或者: from curses import wrapper [as 别名]
def main():
  with Controller.from_port(port = 9051) as controller:
    controller.authenticate()

    try:
      # This makes curses initialize and call draw_bandwidth_graph() with a
      # reference to the screen, followed by additional arguments (in this
      # case just the controller).

      curses.wrapper(draw_bandwidth_graph, controller)
    except KeyboardInterrupt:
      pass  # the user hit ctrl+c 
开发者ID:torproject,项目名称:stem,代码行数:14,代码来源:event_listening.py

示例10: wrapper

# 需要导入模块: import curses [as 别名]
# 或者: from curses import wrapper [as 别名]
def wrapper(cls, func, height=None, catch_interrupt=False, arguments=None,
                unicode_aware=None):
        """
        Construct a new Screen for any platform.  This will initialize the
        Screen, call the specified function and then tidy up the system as
        required when the function exits.

        :param func: The function to call once the Screen has been created.
        :param height: The buffer height for this Screen (only for test purposes).
        :param catch_interrupt: Whether to catch and prevent keyboard
            interrupts.  Defaults to False to maintain backwards compatibility.
        :param arguments: Optional arguments list to pass to func (after the
            Screen object).
        :param unicode_aware: Whether the application can use unicode or not.
            If None, try to detect from the environment if UTF-8 is enabled.
        """
        screen = Screen.open(height,
                             catch_interrupt=catch_interrupt,
                             unicode_aware=unicode_aware)
        restore = True
        try:
            try:
                if arguments:
                    return func(screen, *arguments)
                else:
                    return func(screen)
            except ResizeScreenError:
                restore = False
                raise
        finally:
            screen.close(restore) 
开发者ID:peterbrittain,项目名称:asciimatics,代码行数:33,代码来源:screen.py

示例11: play

# 需要导入模块: import curses [as 别名]
# 或者: from curses import wrapper [as 别名]
def play(self, game):
    """Play a pycolab game.

    Calling this method initialises curses and starts an interaction loop. The
    loop continues until the game terminates or an error occurs.

    This method will exit cleanly if an exception is raised within the game;
    that is, you shouldn't have to reset your terminal.

    Args:
      game: a pycolab game. Ths game must not have had its `its_showtime` method
          called yet.

    Raises:
      RuntimeError: if this method is called while a game is already underway.
    """
    if self._game is not None:
      raise RuntimeError('CursesUi is not at all thread safe')
    self._game = game
    self._start_time = datetime.datetime.now()
    # Inform the croppers which game we're playing.
    for cropper in self._croppers:
      cropper.set_engine(self._game)

    # After turning on curses, set it up and play the game.
    curses.wrapper(self._init_curses_and_play)

    # The game has concluded. Print the final statistics.
    duration = datetime.datetime.now() - self._start_time
    print('Game over! Final score is {}, earned over {}.'.format(
        self._total_return, _format_timedelta(duration)))

    # Clean up in preparation for the next game.
    self._game = None
    self._start_time = None
    self._total_return = None 
开发者ID:deepmind,项目名称:pycolab,代码行数:38,代码来源:human_ui.py

示例12: _update_game_console

# 需要导入模块: import curses [as 别名]
# 或者: from curses import wrapper [as 别名]
def _update_game_console(self, new_log_messages, console, paint_console):
    """Update game console text buffer; draw console to the screen if enabled.

    Args:
      new_log_messages: a list of strings containing new log messages to place
          in the game console's message buffer.
      console: curses window for the game console.
      paint_console: if True, the console will be displayed at the next screen
          refresh; if not, it won't.
    """
    # First we have to format the new messages to fit within our game console.
    rows, cols = console.getmaxyx()

    # Split all log messages on newline characters.
    split_log_messages = []
    for message in new_log_messages:
      split_log_messages.extend(message.splitlines())

    # It's a little weird to wrap console log messages with a text wrapper
    # designed for English text, but that beats writing tab expansion myself.
    wrapper = textwrap.TextWrapper(
        width=cols, drop_whitespace=False, break_on_hyphens=False)
    for message in split_log_messages:
      self._log_messages.extend(wrapper.wrap(message))

    # There's only room on the screen for the last rows-1 console messages.
    del self._log_messages[:(1-rows)]

    # Draw the console if the console is visible.
    if paint_console:
      console.border(' ', ' ', curses.ACS_HLINE, ' ',
                     curses.ACS_ULCORNER, curses.ACS_URCORNER, ' ', ' ')
      console.addstr(0, 4, '{ Console }', curses.A_BOLD)
      console.addstr(1, 0, '\n'.join(self._log_messages))
      console.noutrefresh() 
开发者ID:deepmind,项目名称:pycolab,代码行数:37,代码来源:human_ui.py

示例13: wrapper

# 需要导入模块: import curses [as 别名]
# 或者: from curses import wrapper [as 别名]
def wrapper(func, *args, **kwds):
    """Wrapper function that initializes curses and calls another function,
    restoring normal keyboard/screen behavior on error.
    The callable object 'func' is then passed the main window 'stdscr'
    as its first argument, followed by any other arguments passed to
    wrapper().
    """

    try:
        # Initialize curses
        stdscr = curses.initscr()

        # Turn off echoing of keys, and enter cbreak mode,
        # where no buffering is performed on keyboard input
        curses.noecho()
        curses.cbreak()

        # In keypad mode, escape sequences for special keys
        # (like the cursor keys) will be interpreted and
        # a special value like curses.KEY_LEFT will be returned
        stdscr.keypad(1)

        # Start color, too.  Harmless if the terminal doesn't have
        # color; user can test with has_color() later on.  The try/catch
        # works around a minor bit of over-conscientiousness in the curses
        # module -- the error return from C start_color() is ignorable.
        try:
            curses.start_color()
        except:
            pass

        return func(stdscr, *args, **kwds)
    finally:
        # Set everything back to normal
        if 'stdscr' in locals():
            stdscr.keypad(0)
            curses.echo()
            curses.nocbreak()
            curses.endwin() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:41,代码来源:wrapper.py

示例14: main

# 需要导入模块: import curses [as 别名]
# 或者: from curses import wrapper [as 别名]
def main():
    if os.path.isfile(BASEDIR):
        sys.exit('Please remove your old configuration file at {}'.format(BASEDIR))
    os.makedirs(BASEDIR, exist_ok=True)

    global CONFIG
    CONFIG = read_configuration(CONFFILE)
    locale.setlocale(locale.LC_MONETARY, CONFIG['locale'].get('monetary', ''))

    requests_cache.install_cache(cache_name='api_cache', backend='memory',
        expire_after=int(CONFIG['api'].get('cache', 10)))

    curses.wrapper(mainc) 
开发者ID:huwwp,项目名称:cryptop,代码行数:15,代码来源:cryptop.py

示例15: run

# 需要导入模块: import curses [as 别名]
# 或者: from curses import wrapper [as 别名]
def run(remote):
    """Run interactive remote control application."""
    curses.wrapper(_control, remote) 
开发者ID:Ape,项目名称:samsungctl,代码行数:5,代码来源:interactive.py


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