Hi there,
First off, apologies if this is in the wrong place, but I'm at a loss right now.
I'm trying to learn how to do gui in python, and I am having trouble just getting a window on the screen using this script I found this on this internet. I am fairly sure it is right as it corresponds very well to another thing I was trying, but on execution, nothing happens, the prompt doesn't return any error, just nothing happens, I have left in all credits, as I have copied it directly and just want to get it working:
Code:
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
ZetCode PyQt4 tutorial
In this example, we create a simple
window in PyQt4.
author: Jan Bodnar
website: zetcode.com
last edited: October 2011
"""
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()
sys.exit(app.exec_())
if __name__ == '__main__':
main()
Please can someone enlighten me as to why I am not getting a window on the screen using this code, Yet when I can with this:
Code:
import sys
from PyQt4 import QtGui
app = QtGui.QApplication(sys.argv)
window = QtGui.QWidget()
window.show()
In fact, I just tried putting this in a script and it doesn't work as a script either, so I am doing something very wrong, as it works when you just plug it straight into the shell. However I can print text from a script, that works. I'm at a bit of a loss now, as I must have the right libraries installed to run this, and I can run other python scripts. I am using a Raspberry Pi3 by the way.
Any help on this would be very much appreciated.
IFunction