[英]PyQt4 window does not appears while running the program but appears on ipython
I was trying out PyQt4. 我正在尝试PyQt4。 and tried this code. 并尝试了这段代码。
import sys
from PyQt4 import QtGui
app = QtGui.QApplication(sys.argv)
window = QtGui.QWidget()
window.show()
print 'end'
This above code works when i try it on on ipython
, But it doesn't when i write them into a file and run it. 当我在ipython
上尝试该代码时,以上代码有效,但当我将其写入文件并运行ipython
。 I also tried changing the permission by chmod +x
. 我还尝试通过chmod +x
更改权限。 The code actually runs(the reason i added a print statement at the end to confirm if the code is running till the end), i don't get a window. 代码实际上在运行(我在末尾添加打印语句以确认代码是否一直运行到末尾的原因),我没有窗口。
im running python 2.7.6 on ubuntu 14.04 我在Ubuntu 14.04上运行python 2.7.6
初始化小部件并在主窗口上调用show()
,需要通过调用app.exec_()
启动Qt事件循环。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.