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


Python blessed.Terminal类代码示例

本文整理汇总了Python中blessed.Terminal的典型用法代码示例。如果您正苦于以下问题:Python Terminal类的具体用法?Python Terminal怎么用?Python Terminal使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: __init__

 def __init__(self, kind, stream, rows, columns):
     """ Class initializer. """
     self._rows = rows
     self._columns = columns
     BlessedTerminal.__init__(self, kind, stream)
     if sys.platform.lower().startswith('win32'):
         self._normal = '\x1b[m'
开发者ID:adammendoza,项目名称:x84,代码行数:7,代码来源:terminal.py

示例2: participant_context

def participant_context(exp: Experiment, participant: ExperimentSection):
    term = Terminal()
    exp.session_data['term'] = term
    exp.session_data['stimuli'] = [
        jpg_to_ascii(os.path.join('stimuli', '{:02}.jpg'.format(i)), background='light', height=term.height - 2)
        for i in range(1, 16)
    ]

    with term.fullscreen():
        print(term.move(int(term.width//2), int(term.height//2)))
        response_type = participant.data['response_type']
        instructions = exp.experiment_data['instructions']
        for i, instruction in enumerate(instructions, 1):
            message = get_message(instruction, response_type)

            if message.startswith('_example'):
                show_example(term, response_type, message.split('_')[2], exp.session_data['stimuli'],
                             exp.experiment_data['example_response_message'],
                             ascii_stimuli=exp.experiment_data.get('ascii_stimuli', True),
                             stimulus_time=8)

            else:
                reset(term)
                wrapped_multiline_print_at_location(term, message, X_MARGIN, Y_MARGIN, int(term.width//2))
                with term.location(term.width//2, term.height - 3):
                    print('{}/{}'.format(i, len(instructions)))
                time.sleep(1)  # Ensure we don't accidentally skip a message.
                input()
        yield
        reset(term)
        print(exp.experiment_data['exit_message'])
        input()

    del exp.session_data['term']
开发者ID:hsharrison,项目名称:bistable-perception-experiment,代码行数:34,代码来源:experiment.py

示例3: inputter

def inputter():
    term = Terminal()
    with term.cbreak():
        key = term.inkey(1)
        if key and not key.is_sequence:
            return key
        return None
开发者ID:grobolom,项目名称:TwitterCLI,代码行数:7,代码来源:main.py

示例4: main

def main():
    """
    Displays all known key capabilities that may match the terminal.
    As each key is pressed on input, it is lit up and points are scored.
    """
    try:
        from x84.bbs import getterminal, echo

        term = getterminal()
    except (ImportError, AttributeError):
        from blessed import Terminal
        import sys

        term = Terminal()

        def echo(text):
            sys.stdout.write(u"{}".format(text))
            sys.stdout.flush()

    echo(u"".join((term.normal, term.height * u"\r\n", term.home, term.clear_eos)))

    with term.raw():
        inp = u""
        echo(u"Press Q to exit.\r\n")
        while inp.upper() != "Q":
            inp = term.inkey(timeout=10.0)
            disp_inp = inp.__str__() if inp.is_sequence else inp
            echo(u"{0!r}: code={1!r} name={2!r}\r\n".format(disp_inp, inp.code, inp.name))
开发者ID:gofore,项目名称:x84,代码行数:28,代码来源:test_keyboard_keys.py


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