从PyQt事件循环中执行Python代码 [英] Execute Python code from within PyQt event loop
问题描述
我发现运行PyQt循环的这个示例在一个线程,但不想做一些非常规的事情。有没有办法得到PyQt消息循环来继续处理消息,同时在exec_被调用之后执行主线程中的python代码?
最简单的方法是使用IPython:
ipython --gui = qt4
请参阅 ipython --help
或在线文档获取更多选项(例如gtk,tk等)。
I am testing a gui built using PyQt and I would like the ability to interact with the gui using python code that is executed after the PyQt event loop starts (app.exec_()). Another way of saying this is I would like the call to app.exec_ to return immediately as if the gui were modeless, followed by further python code which interacts with the gui.
I found this example of running the PyQt loop in a thread but don't want to do something so unconventional. Is there any way to get the PyQt message loop to continue processing messages while also executing python code in the main thread after exec_ has been called?
The easiest way is to use IPython:
ipython --gui=qt4
See ipython --help
or the online documentation for more options (e.g. gtk, tk, etc).
这篇关于从PyQt事件循环中执行Python代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!