问题
I am running a twisted process which needs to interact with the user, without blocking. The idea is that the user will be asked to input some data, and once a complete line has been entered, the program will process it, eventually triggering events. During the period that the user is entering data, the reactor must keep on running normally.
Is there any support in twisted for that?
回答1:
You can read from standard input using twisted.internet.stdio. See stdiodemo.py and stdin.py at http://twistedmatrix.com/documents/current/core/examples/.
You can also use Gtk using twisted.internet.gtk2reactor. See the pbgtk2.py example at the same examples page.
You can also use other GUI toolkits, though Gtk is the most well supported.
来源:https://stackoverflow.com/questions/8532387/user-interaction-in-twisted-process