This is template for PyQt application. It's good point to start studying PyQt.
- create ui-file in QtDesigner
- save it to disk
- replace 'c:/test.ui' with real path to created ui
- execute py-file. Make sure to run it with pythonw, not with python. In this case, command window will not pop up (on windows system).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | from PyQt4 import QtGui, uic import sys # replace 'c:/test.ui' with real path to ui-file created in QtDesigner uifile = 'c:/test.ui' form, base = uic.loadUiType(uifile) class testQtWindow(QtGui.QMainWindow): def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.ui = form() self.ui.setupUi(self) def main(): app = QtGui.QApplication(sys.argv) myapp = testQtWindow() myapp.show() sys.exit(app.exec_()) if __name__=="__main__": main() |
No comments:
Post a Comment