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


Python Token.Toolbar方法代码示例

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


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

示例1: ask_for_receiver

# 需要导入模块: from prompt_toolkit.token import Token [as 别名]
# 或者: from prompt_toolkit.token.Token import Toolbar [as 别名]
def ask_for_receiver(self, args, members):
        member_names = dict(itertools.chain(
            ((m.name, m) for m in members if m.name is not None and len(m.name) != 0),
            (('{}({})'.format(m.id[:6], m.name), m) for m in members),
            (('{}({})'.format(m.id, m.name), m) for m in members),
        ))
        completer = WordCompleter(sorted(member_names.keys()))
        toolbar = lambda _: [(Token.Toolbar, 'Send {}: Insert the name, id or short id of the receiver'.format(args.amount))]
        try:
            member = prompt('Insert receiver: ', get_bottom_toolbar_tokens=toolbar, style=self.style,
                            completer=completer, complete_while_typing=True)
            if member in member_names:
                receiver = member_names[member]
                bptc.logger.info("Transfering {} BPTC to {} with comment '{}'".format(args.amount, receiver, args.comment))
                self.network.send_transaction(args.amount, args.comment, receiver)
            else:
                print('Invalid member name: {}'.format(member))
        except (EOFError, KeyboardInterrupt):
            pass 
开发者ID:ceddie,项目名称:bptc_wallet,代码行数:21,代码来源:console_app.py

示例2: get_bottom_toolbar_tokens

# 需要导入模块: from prompt_toolkit.token import Token [as 别名]
# 或者: from prompt_toolkit.token.Token import Toolbar [as 别名]
def get_bottom_toolbar_tokens(cli):
    return [(Token.Toolbar, ' F10 : Exit ')] 
开发者ID:yasintoy,项目名称:Slack-Gitsin,代码行数:4,代码来源:main.py

示例3: __init__

# 需要导入模块: from prompt_toolkit.token import Token [as 别名]
# 或者: from prompt_toolkit.token.Token import Toolbar [as 别名]
def __init__(self, title='Interactive Shell', add_help=True):
        self.title = title
        self.style = style_from_dict({
            Token.Toolbar: '#ffffff bg:#333333',
        })
        if add_help:
            self.commands['help'] = dict(
                help = 'Show this help message',
            )
        self.history = InMemoryHistory()
        self.completer = WordCompleter(sorted(self.commands.keys()))
        self.parser = self._create_parser()
        self.registry = self._create_keybindings_registry() 
开发者ID:ceddie,项目名称:bptc_wallet,代码行数:15,代码来源:interactive_shell.py

示例4: _get_toolbar

# 需要导入模块: from prompt_toolkit.token import Token [as 别名]
# 或者: from prompt_toolkit.token.Token import Toolbar [as 别名]
def _get_toolbar(self, cli):
        return [(Token.Toolbar, 'Actions: {}'.format(', '.join(self.commands)))] 
开发者ID:ceddie,项目名称:bptc_wallet,代码行数:4,代码来源:interactive_shell.py

示例5: get_bottom_toolbar_tokens

# 需要导入模块: from prompt_toolkit.token import Token [as 别名]
# 或者: from prompt_toolkit.token.Token import Toolbar [as 别名]
def get_bottom_toolbar_tokens(cli):
    return [(Token.Toolbar, '??: 1.query: ????  2.????: !run xxx  3.????: !debug ')] 
开发者ID:wwj718,项目名称:yige-python,代码行数:4,代码来源:send_text_example_prompt.py

示例6: get_bottom_toolbar_tokens

# 需要导入模块: from prompt_toolkit.token import Token [as 别名]
# 或者: from prompt_toolkit.token.Token import Toolbar [as 别名]
def get_bottom_toolbar_tokens(self, cli):
        return [(Token.Toolbar, 'Run '),
                (Token.Name, self.run_name),
                (Token.Toolbar, ' in progress.')] 
开发者ID:crowsonkb,项目名称:style_transfer,代码行数:6,代码来源:prompt.py

示例7: shell

# 需要导入模块: from prompt_toolkit.token import Token [as 别名]
# 或者: from prompt_toolkit.token.Token import Toolbar [as 别名]
def shell():
    c = Chitin()

    cmd_history = FileHistory(os.path.expanduser('~') + '/.chitin.history')
    print(WELCOME)
    message = VERSION

    def get_bottom_toolbar_tokens(cli):
        return [(Token.Toolbar, ' '+message)]

    style = style_from_dict({
        Token.Toolbar: '#ffffff bg:#333333',
    })
    completer = SystemCompleter()
    del completer.completers["executable"]

    # Check whether files in and around the current directory have been changed...
    for failed in util.check_integrity_set(set(".")):
        print("[WARN] '%s' has been modified outside of lab book." % failed)
    try:
        while True:
            cmd_str = ""
            while len(cmd_str.strip()) == 0:
                cmd_str = prompt(u'===> ',
                        history=cmd_history,
                        auto_suggest=AutoSuggestFromHistory(),
                        completer=completer,
                        lexer=PygmentsLexer(BashLexer),
                        get_bottom_toolbar_tokens=get_bottom_toolbar_tokens,
                        style=style,
                        on_abort=AbortAction.RETRY,
                )


            fields = cmd_str.split(" ")
            command_set = [" ".join(fields)]

            skip, special_command_set = c.attempt_special(cmd_str)
            if skip:
                continue
            if len(special_command_set) > 0:
                command_set = special_command_set

            #####################################
            handled = c.super_handle(command_set)
            if handled:
                if "message" in handled:
                    message = handled["message"]
                else:
                    message = VERSION
            #####################################

    except EOFError:
        print("Bye!") 
开发者ID:SamStudio8,项目名称:chitin,代码行数:56,代码来源:__init__.py

示例8: run

# 需要导入模块: from prompt_toolkit.token import Token [as 别名]
# 或者: from prompt_toolkit.token.Token import Toolbar [as 别名]
def run(self):
        style = style_from_dict({
            Token.Prompt: 'bold',
            Token.Toolbar: '#ccc bg:#333',
            Token.Name: '#fff bold bg:#333',
        })

        history = InMemoryHistory()
        eventloop = create_eventloop()
        app = create_prompt_application(history=history, style=style,
                                        get_bottom_toolbar_tokens=self.get_bottom_toolbar_tokens,
                                        get_prompt_tokens=self.get_prompt_tokens)
        self.cli = CommandLineInterface(app, eventloop)

        with self.cli.patch_stdout_context(raw=True):
            while True:
                try:
                    self.cli.run()
                    doc = self.cli.return_value()
                    if doc is None:
                        return
                    cmd = shlex.split(doc.text)
                    app.buffer.reset(append_to_history=True)

                    if not cmd:
                        continue
                    elif cmd[0] in ('exit', 'quit'):
                        self.q.put(Exit())
                        return
                    elif cmd[0] == 'help':
                        print('Help text forthcoming.')
                    elif cmd[0] == 'skip':
                        self.q.put(Skip())
                    elif cmd[0] == 'set':
                        self.q.put(Set(cmd[1], ast.literal_eval(' '.join(cmd[2:]))))
                    else:
                        print('Unknown command. Try \'help\'.')
                except KeyboardInterrupt:
                    continue
                except EOFError:
                    self.q.put(Exit())
                    return
                except Exception as err:
                    print(err)
                    self.q.put(Exit())
                    return 
开发者ID:crowsonkb,项目名称:style_transfer,代码行数:48,代码来源:prompt.py


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