本文整理汇总了Python中prompt_toolkit.CommandLineInterface.read_input_async方法的典型用法代码示例。如果您正苦于以下问题:Python CommandLineInterface.read_input_async方法的具体用法?Python CommandLineInterface.read_input_async怎么用?Python CommandLineInterface.read_input_async使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类prompt_toolkit.CommandLineInterface
的用法示例。
在下文中一共展示了CommandLineInterface.read_input_async方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: interactive_shell
# 需要导入模块: from prompt_toolkit import CommandLineInterface [as 别名]
# 或者: from prompt_toolkit.CommandLineInterface import read_input_async [as 别名]
def interactive_shell():
"""
Coroutine that shows the interactive command line.
"""
# Create interface. (style/layout is only for demonstration.)
cli = CommandLineInterface(
layout=Layout(before_input=DefaultPrompt(text='Say something inside the event loop: ')),
style=TestStyle)
# Patch stdout in something that will always print *above* the prompt when
# something is written to stdout.
sys.stdout = cli.stdout_proxy()
# Run echo loop. Read text from stdin, and reply it back.
while True:
try:
result = yield from cli.read_input_async(
on_exit=AbortAction.RAISE_EXCEPTION,
on_abort=AbortAction.RAISE_EXCEPTION)
print('You said: "%s"' % result.text)
except (Exit, Abort):
loop.stop()
print('Qutting event loop. Bye.')
return