I have just designed my application inside pyQt Designer 5, generated my main.ui to main.py and my assets.qrc to assets_rc.py. No errors, when I now run main.py from my terminal nothing happends. Have I missed a step? Am I supposed to edit my main.py file now?
Python 3.3.0 pyQT 5
This is for
PyQt4, but should be the same for
Let's say your ui is called "mainwindow.ui". Compile this with pyuic4 into "mainWindowUi.py" (or whatever, just stick to the name).
Now create a file "mainWindow.py" with more or less this content:
from PyQt4 import QtGui from mainWindowUi import Ui_MainWindow #same name as appears in mainWindowUi.py class MainWindow (QtGui.QMainWindow): #Or wherever you are inheriting from def __init__ (self, parent = None): super (MainWindow, self).__init__ () self.ui = Ui_MainWindow () #same name as appears in mainWindowUi.py self.ui.setupUi (self) #implement slots and signals and other funny things
Now create a file "program.py" with more or less this content:
#! /usr/bin/python3.3 import sys from PyQt4 import QtGui from mainWindow import MainWindow def main(): app = QtGui.QApplication (sys.argv) m = MainWindow () m.show () sys.exit (app.exec_ () ) if __name__ == '__main__': main ()
program.py file. This is more or less the skeleton of a Qt application.