Reputation: 11
I am a beginner learning PyQt and the following code is not displaying any window on the screen, though I can see that the build is successful. I'm not able to recognize the mistake, could you help me please?
#!/usr/bin/python
import sys
from PyQt4 import QtGui
def main():
app = QtGui.QApplication(sys.argv)
w = QtGui.QWidget()
w.resize(250, 150)
w.move(300, 300)
w.setWindowTitle('Simple')
w.show()
app.exec_()
if __name__ == '__main__':
main()
Upvotes: 1
Views: 8166
Reputation: 86
Try to add sys.exit(app.exec_())
at the end of main()
function.
This worked for me (I use python3):
import sys
from PyQt4 import QtGui
app = QtGui.QApplication(sys.argv)
frame = QtGui.QMainWindow()
frame.setGeometry(50, 50, 600, 400)
frame.setWindowTitle('FrameTitle')
frame.show()
sys.exit(app.exec_())
Upvotes: 4