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


Python shortcuts.prompt方法代码示例

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


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

示例1: bootstrap_prompt

# 需要导入模块: from prompt_toolkit import shortcuts [as 别名]
# 或者: from prompt_toolkit.shortcuts import prompt [as 别名]
def bootstrap_prompt(prompt_kwargs, group):
    """
    Bootstrap prompt_toolkit kwargs or use user defined values.

    :param prompt_kwargs: The user specified prompt kwargs.
    """
    prompt_kwargs = prompt_kwargs or {}

    defaults = {
        "history": InMemoryHistory(),
        "completer": ClickCompleter(group),
        "message": u"> ",
    }

    for key in defaults:
        default_value = defaults[key]
        if key not in prompt_kwargs:
            prompt_kwargs[key] = default_value

    return prompt_kwargs 
开发者ID:click-contrib,项目名称:click-repl,代码行数:22,代码来源:__init__.py

示例2: continue_prompt

# 需要导入模块: from prompt_toolkit import shortcuts [as 别名]
# 或者: from prompt_toolkit.shortcuts import prompt [as 别名]
def continue_prompt(message=""):
    """Prompt the user to continue or not

    Returns True when the user type Yes.

    :param message: message to display
    :type message: str

    :rtype: bool
    """
    answer = False
    message = message + "\n'Yes' or 'No' to continue: "
    while answer not in ('Yes', 'No'):
        answer = prompt(message, eventloop=eventloop())
        if answer == "Yes":
            answer = True
            break
        if answer == "No":
            answer = False
            break
    return answer 
开发者ID:eonpatapon,项目名称:contrail-api-cli,代码行数:23,代码来源:utils.py

示例3: main

# 需要导入模块: from prompt_toolkit import shortcuts [as 别名]
# 或者: from prompt_toolkit.shortcuts import prompt [as 别名]
def main():
    # We wrap it in a ThreadedCompleter, to make sure it runs in a different
    # thread. That way, we don't block the UI while running the completions.
    slow_completer = SlowCompleter()

    # Add a bottom toolbar that display when completions are loading.
    def bottom_toolbar():
        return " Loading completions... " if slow_completer.loading > 0 else ""

    # Display prompt.
    text = prompt(
        "Give some animals: ",
        completer=slow_completer,
        complete_in_thread=True,
        complete_while_typing=True,
        bottom_toolbar=bottom_toolbar,
        complete_style=CompleteStyle.MULTI_COLUMN,
    )
    print("You said: %s" % text) 
开发者ID:prompt-toolkit,项目名称:python-prompt-toolkit,代码行数:21,代码来源:slow-completions.py

示例4: run

# 需要导入模块: from prompt_toolkit import shortcuts [as 别名]
# 或者: from prompt_toolkit.shortcuts import prompt [as 别名]
def run(self):
        """ Main entry function. """
        history = InMemoryHistory()
        self._load_file()

        while True:
            # (re)load the todo.txt file (only if it has been modified)

            try:
                user_input = prompt(u'topydo> ', history=history,
                                    completer=self.completer,
                                    complete_while_typing=False)
                user_input = shlex.split(user_input)
            except EOFError:
                sys.exit(0)
            except KeyboardInterrupt:
                continue
            except ValueError as verr:
                error('Error: ' + str(verr))
                continue

            try:
                (subcommand, args) = get_subcommand(user_input)
            except ConfigError as ce:
                error('Error: ' + str(ce) + '. Check your aliases configuration')
                continue

            try:
                if self._execute(subcommand, args) != False:
                    self._post_execute()
            except TypeError:
                print(GENERIC_HELP) 
开发者ID:bram85,项目名称:topydo,代码行数:34,代码来源:Prompt.py

示例5: main

# 需要导入模块: from prompt_toolkit import shortcuts [as 别名]
# 或者: from prompt_toolkit.shortcuts import prompt [as 别名]
def main():
    """ Main entry point of the prompt interface. """
    PromptApplication().run() 
开发者ID:bram85,项目名称:topydo,代码行数:5,代码来源:Prompt.py

示例6: run

# 需要导入模块: from prompt_toolkit import shortcuts [as 别名]
# 或者: from prompt_toolkit.shortcuts import prompt [as 别名]
def run(self):
        buf = ""

        self.logger.handle("Commands available: list | quit | check [CVE_NUMBER] | exploit [CVE_NUMBER]", None)
        while True:
            buf = prompt("\nDrupwn> ", history=self.history, completer=self.auto_cmds, complete_while_typing=False)
            args = buf.split(" ")
            try:
                if args[0] == "quit":
                    break
                self.cmds[args[0]](args)
            except:
                pass 
开发者ID:immunIT,项目名称:drupwn,代码行数:15,代码来源:Exploiter.py

示例7: interact

# 需要导入模块: from prompt_toolkit import shortcuts [as 别名]
# 或者: from prompt_toolkit.shortcuts import prompt [as 别名]
def interact(connection):
    clear()
    connection.send("Welcome!\n")

    # Ask for input.
    result = await prompt(message="Say something: ", async_=True)

    # Send output.
    connection.send("You said: {}\n".format(result))
    connection.send("Bye.\n") 
开发者ID:prompt-toolkit,项目名称:python-prompt-toolkit,代码行数:12,代码来源:hello-world.py

示例8: main

# 需要导入模块: from prompt_toolkit import shortcuts [as 别名]
# 或者: from prompt_toolkit.shortcuts import prompt [as 别名]
def main():
    answer = prompt("Give me some input: ", lexer=RainbowLexer())
    print("You said: %s" % answer) 
开发者ID:prompt-toolkit,项目名称:python-prompt-toolkit,代码行数:5,代码来源:custom-lexer.py

示例9: get_prompt

# 需要导入模块: from prompt_toolkit import shortcuts [as 别名]
# 或者: from prompt_toolkit.shortcuts import prompt [as 别名]
def get_prompt():
    " Tokens to be shown before the prompt. "
    now = datetime.datetime.now()
    return [
        ("bg:#008800 #ffffff", "%s:%s:%s" % (now.hour, now.minute, now.second)),
        ("bg:cornsilk fg:maroon", " Enter something: "),
    ] 
开发者ID:prompt-toolkit,项目名称:python-prompt-toolkit,代码行数:9,代码来源:clock-input.py

示例10: main

# 需要导入模块: from prompt_toolkit import shortcuts [as 别名]
# 或者: from prompt_toolkit.shortcuts import prompt [as 别名]
def main():
    result = prompt(get_prompt, refresh_interval=0.5)
    print("You said: %s" % result) 
开发者ID:prompt-toolkit,项目名称:python-prompt-toolkit,代码行数:5,代码来源:clock-input.py

示例11: main

# 需要导入模块: from prompt_toolkit import shortcuts [as 别名]
# 或者: from prompt_toolkit.shortcuts import prompt [as 别名]
def main():
    text = prompt(
        "Give some animals: ",
        completer=animal_completer,
        complete_style=CompleteStyle.MULTI_COLUMN,
    )
    print("You said: %s" % text) 
开发者ID:prompt-toolkit,项目名称:python-prompt-toolkit,代码行数:9,代码来源:multi-column-autocompletion-with-meta.py

示例12: main

# 需要导入模块: from prompt_toolkit import shortcuts [as 别名]
# 或者: from prompt_toolkit.shortcuts import prompt [as 别名]
def main():
    text = prompt(
        "Give some animals: ", completer=animal_completer, complete_while_typing=True
    )
    print("You said: %s" % text) 
开发者ID:prompt-toolkit,项目名称:python-prompt-toolkit,代码行数:7,代码来源:fuzzy-word-completer.py

示例13: main

# 需要导入模块: from prompt_toolkit import shortcuts [as 别名]
# 或者: from prompt_toolkit.shortcuts import prompt [as 别名]
def main():
    text = prompt(
        "Give some animals: ",
        completer=animal_completer,
        complete_style=CompleteStyle.READLINE_LIKE,
    )
    print("You said: %s" % text) 
开发者ID:prompt-toolkit,项目名称:python-prompt-toolkit,代码行数:9,代码来源:autocompletion-like-readline.py

示例14: prompt

# 需要导入模块: from prompt_toolkit import shortcuts [as 别名]
# 或者: from prompt_toolkit.shortcuts import prompt [as 别名]
def prompt(self):
        message = [
            ('class:pygments.os',    OS_MATCHING[self.os]),
            ('class:pygments.colon', ':'),
            ('class:pygments.mode',  self.mode),
            ('class:pygments.colon', ':'),
            ('class:pygments.arch',  self.pexec.arch),
            ('class:pygments.pound', ' > ')
        ]

        return prompt(message, style=self.prompt_style, history=self.__get_history()) 
开发者ID:merrychap,项目名称:shellen,代码行数:13,代码来源:shell.py

示例15: irun

# 需要导入模块: from prompt_toolkit import shortcuts [as 别名]
# 或者: from prompt_toolkit.shortcuts import prompt [as 别名]
def irun(self):
        while True:
            try:
                cmd = self.prompt()
                if cmd == '':
                    continue
                else:
                    if not self.handle_command(cmd):
                        cprint('\n<red,bold>[-]</> Invalid command.\n')
            except Exception as e:
                cprint('\n<red,bold>[-]</> Error occured: {}\n'.format(e))
            except KeyboardInterrupt:
                cprint() 
开发者ID:merrychap,项目名称:shellen,代码行数:15,代码来源:shell.py


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