【发布时间】:2013-01-05 14:37:33
【问题描述】:
我正在使用 Python 2.6 开发 GUI 前端,通常它相当简单:您使用 subprocess.call() 或 subprocess.Popen() 发出命令并等待它完成或对错误作出反应。如果你有一个程序停止并等待用户交互,你会怎么做?例如,程序可能会停止并询问用户 ID 和密码或如何处理错误?
c:\> parrot
Military Macaw - OK
Sun Conure - OK
African Grey - OK
Norwegian Blue - Customer complaint!
(r) he's Resting, (h) [Hit cage] he moved, (p) he's Pining for the fjords
到目前为止,我所阅读的所有内容都告诉您如何仅在 完成后读取程序的所有输出,而不是在程序仍在运行时如何处理输出。我无法安装新模块(这是针对 LiveCD 的),而且我将多次处理用户输入。
【问题讨论】:
-
您的意思是让子进程像命令行客户端一样工作?
标签: python command-line subprocess popen frontend