Can't Start Designed Pyqt Application
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 no
Solution 1:
This is for PyQt4
, but should be the same for PyQt5
.
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.pyclassMainWindow (QtGui.QMainWindow): #Or wherever you are inheriting fromdef__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.3import sys
from PyQt4 import QtGui
from mainWindow import MainWindow
defmain():
app = QtGui.QApplication (sys.argv)
m = MainWindow ()
m.show ()
sys.exit (app.exec_ () )
if __name__ == '__main__':
main ()
Run the program.py
file. This is more or less the skeleton of a Qt application.
Post a Comment for "Can't Start Designed Pyqt Application"