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


Python blessed.Terminal方法代码示例

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


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

示例1: test_termcap_repr

# 需要导入模块: import blessed [as 别名]
# 或者: from blessed import Terminal [as 别名]
def test_termcap_repr():
    "Ensure ``hidden_cursor()`` writes hide_cursor and normal_cursor."

    given_ttype='vt220'
    given_capname = 'cursor_up'
    expected = [r"<Termcap cursor_up:'\x1b\\[A'>",
                r"<Termcap cursor_up:'\\\x1b\\[A'>",
                r"<Termcap cursor_up:u'\\\x1b\\[A'>"]

    @as_subprocess
    def child():
        import blessed
        term = blessed.Terminal(given_ttype)
        given = repr(term.caps[given_capname])
        assert given in expected

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

示例2: load_theme_from_json

# 需要导入模块: import blessed [as 别名]
# 或者: from blessed import Terminal [as 别名]
def load_theme_from_json(json_theme):
    """
    Load a theme from a json.
    Expected format:
    {
        "Question": {
            "mark_color": "yellow",
            "brackets_color": "normal",
            ...
        },
        "List": {
            "selection_color": "bold_blue",
            "selection_cursor": "->"
        }
    }

    Color values should be string representing valid blessings.Terminal colors.
    """
    return load_theme_from_dict(json.loads(json_theme)) 
开发者ID:magmax,项目名称:python-inquirer,代码行数:21,代码来源:themes.py

示例3: setUp

# 需要导入模块: import blessed [as 别名]
# 或者: from blessed import Terminal [as 别名]
def setUp(self):
        self.term = Terminal()
        self.theme_dict = {
            'Question': {
                'mark_color': 'red',
                'brackets_color': 'yellow'
            },
            'List': {
                'selection_color': 'red',
                'selection_cursor': '->'
            }
        }
        self.theme_dict_wrong_field = {
            'Question': {
                'ark_color': 'red'
            }
        }
        self.theme_dict_wrong_question = {
            'questionn': {
                'mark_color': 'red'
            }
        } 
开发者ID:magmax,项目名称:python-inquirer,代码行数:24,代码来源:test_theme.py

示例4: test_export_only_Terminal

# 需要导入模块: import blessed [as 别名]
# 或者: from blessed import Terminal [as 别名]
def test_export_only_Terminal():
    "Ensure only Terminal instance is exported for import * statements."
    import blessed
    assert blessed.__all__ == ('Terminal',) 
开发者ID:QData,项目名称:deepWordBug,代码行数:6,代码来源:test_core.py

示例5: test_null_fileno

# 需要导入模块: import blessed [as 别名]
# 或者: from blessed import Terminal [as 别名]
def test_null_fileno():
    "Make sure ``Terminal`` works when ``fileno`` is ``None``."
    @as_subprocess
    def child():
        # This simulates piping output to another program.
        out = six.StringIO()
        out.fileno = None
        t = TestTerminal(stream=out)
        assert (t.save == u'')

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

示例6: init_terminal

# 需要导入模块: import blessed [as 别名]
# 或者: from blessed import Terminal [as 别名]
def init_terminal():
    global terminal
    if terminal:
        return
    else:
        if sys.platform.startswith('win'):
            terminal = WindowsTerminal()

        else:
            from blessed import Terminal
            terminal = Terminal()

        io.echo(terminal.clear()) 
开发者ID:QData,项目名称:deepWordBug,代码行数:15,代码来源:term.py

示例7: __init__

# 需要导入模块: import blessed [as 别名]
# 或者: from blessed import Terminal [as 别名]
def __init__(self):
        self.term = Terminal()
        self.roku = None 
开发者ID:ncmiller,项目名称:roku-cli,代码行数:5,代码来源:cli.py

示例8: display

# 需要导入模块: import blessed [as 别名]
# 或者: from blessed import Terminal [as 别名]
def display(self):
        """Render current tile and its items. Recurse into nested splits
        if any.
        """
        try:
            t = self._terminal
        except AttributeError:
            t = self._terminal = Terminal()
            tbox = TBox(t, 0, 0, t.width, t.height - 1)
            self._fill_area(tbox.t, 0, 0, t.width, t.height - 1, "f")  # FIXME

        tbox = TBox(t, 0, 0, t.width, t.height - 1)
        self._display(tbox, None)
        # park cursor in a safe place and reset color
        print(t.move(t.height - 3, 0) + t.color(0)) 
开发者ID:FedericoCeratto,项目名称:dashing,代码行数:17,代码来源:dashing.py

示例9: __init__

# 需要导入模块: import blessed [as 别名]
# 或者: from blessed import Terminal [as 别名]
def __init__(self, pterminal = None, prefix="Controller",lineno=0):
        self.terminal = Terminal() if not pterminal else pterminal
        self.prefix = prefix
        self.lineno = lineno 
开发者ID:nnewsom,项目名称:webbies,代码行数:6,代码来源:TerminalWrapper.py

示例10: __init__

# 需要导入模块: import blessed [as 别名]
# 或者: from blessed import Terminal [as 别名]
def __init__(self, event_generator=None, theme=None, *args, **kwargs):
        super(ConsoleRender, self).__init__(*args, **kwargs)
        self._event_gen = event_generator or events.KeyEventGenerator()
        self.terminal = Terminal()
        self._previous_error = None
        self._position = 0
        self._theme = theme or themes.Default() 
开发者ID:magmax,项目名称:python-inquirer,代码行数:9,代码来源:__init__.py

示例11: __init__

# 需要导入模块: import blessed [as 别名]
# 或者: from blessed import Terminal [as 别名]
def __init__(self, question, theme=None, terminal=None, show_default=False,
                 *args, **kwargs):
        super(BaseConsoleRender, self).__init__(*args, **kwargs)
        self.question = question
        self.terminal = terminal or Terminal()
        self.answers = {}
        self.theme = theme
        self.show_default = show_default 
开发者ID:magmax,项目名称:python-inquirer,代码行数:10,代码来源:base.py

示例12: load_theme_from_dict

# 需要导入模块: import blessed [as 别名]
# 或者: from blessed import Terminal [as 别名]
def load_theme_from_dict(dict_theme):
    """
    Load a theme from a dict.
    Expected format:
    {
        "Question": {
            "mark_color": "yellow",
            "brackets_color": "normal",
            ...
        },
        "List": {
            "selection_color": "bold_blue",
            "selection_cursor": "->"
        }
    }

    Color values should be string representing valid blessings.Terminal colors.
    """
    t = Default()
    for question_type, settings in dict_theme.items():
        if question_type not in vars(t):
            raise ThemeError('Error while parsing theme. Question type '
                             '`{}` not found or not customizable.'
                             .format(question_type))

        # calculating fields of namedtuple, hence the filtering
        question_fields = list(filter(lambda x: not x.startswith('_'),
                                      vars(getattr(t, question_type))))

        for field, value in settings.items():
            if field not in question_fields:
                raise ThemeError('Error while parsing theme. Field '
                                 '`{}` invalid for question type `{}`'
                                 .format(field, question_type))
            actual_value = getattr(term, value) or value
            setattr(getattr(t, question_type), field, actual_value)
    return t 
开发者ID:magmax,项目名称:python-inquirer,代码行数:39,代码来源:themes.py

示例13: test_win32_missing_tty_modules

# 需要导入模块: import blessed [as 别名]
# 或者: from blessed import Terminal [as 别名]
def test_win32_missing_tty_modules(monkeypatch):
    "Ensure dummy exception is used when io is without UnsupportedOperation."
    @as_subprocess
    def child():
        OLD_STYLE = False
        try:
            original_import = getattr(__builtins__, '__import__')
            OLD_STYLE = True
        except AttributeError:
            original_import = __builtins__['__import__']

        tty_modules = ('termios', 'fcntl', 'tty')

        def __import__(name, *args, **kwargs):
            if name in tty_modules:
                raise ImportError
            return original_import(name, *args, **kwargs)

        for module in tty_modules:
            sys.modules.pop(module, None)

        warnings.filterwarnings("error", category=UserWarning)
        try:
            if OLD_STYLE:
                __builtins__.__import__ = __import__
            else:
                __builtins__['__import__'] = __import__
            try:
                import blessed.terminal
                imp.reload(blessed.terminal)
            except UserWarning:
                err = sys.exc_info()[1]
                assert err.args[0] == blessed.terminal._MSG_NOSUPPORT

            warnings.filterwarnings("ignore", category=UserWarning)
            import blessed.terminal
            imp.reload(blessed.terminal)
            assert not blessed.terminal.HAS_TTY
            term = blessed.terminal.Terminal('ansi')
            # https://en.wikipedia.org/wiki/VGA-compatible_text_mode
            # see section '#PC_common_text_modes'
            assert term.height == 25
            assert term.width == 80

        finally:
            if OLD_STYLE:
                setattr(__builtins__, '__import__', original_import)
            else:
                __builtins__['__import__'] = original_import
            warnings.resetwarnings()
            import blessed.terminal
            imp.reload(blessed.terminal)

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


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