Revision: 40630
Updated Code
at February 4, 2011 15:21 by blackthorne
Updated Code
import sys from PyQt4.QtCore import * from PyQt4.QtGui import * from <REPLACE_BY_PYUI_DESIGN> import <REPLACE_BY_WINDOW_CLASS_IN_PYUI_DESIGN> class MainWindow(QMainWindow, <REPLACE_BY_WINDOW_CLASS_IN_PYUI_DESIGN>): # custom slot def mymethod(self): self.textFieldExample.setText('Hello World') self.textFieldExample.clear() def __init__(self): QMainWindow.__init__(self) # set up User Interface (widgets, layout...) self.setupUi(self) # custom slots connections QObject.connect(self.pushButton,SIGNAL("released()"),self.mymethod) # signal/slot connection # Main entry to program. Sets up the main app and create a new window. def main(argv): # create Qt application app = QApplication(argv,True) # create main window wnd = MainWindow() # classname wnd.show() # Connect signal for app finish app.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()")) # Start the app up sys.exit(app.exec_()) if __name__ == "__main__": main(sys.argv)
Revision: 40629
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at February 4, 2011 15:16 by blackthorne
Initial Code
import sys from PyQt4.QtCore import * from PyQt4.QtGui import * from <REPLACE_BY_PYUI_DESIGN> import <REPLACE_BY_WINDOW_CLASS_IN_PYUI_DESIGN> class MainWindow(QMainWindow, <REPLACE_BY_WINDOW_CLASS_IN_PYUI_DESIGN>): # custom slot def mymethod(self): self.textFieldExample.setText('Hello World') self.textFieldExample.clear() def __init__(self): QMainWindow.__init__(self) # set up User Interface (widgets, layout...) self.setupUi(self) # custom slots connections QObject.connect(self.pushButton,SIGNAL("released()"),self.mymethod) # signal/slot connection # Main entry to program. Sets up the main app and create a new window. def main(argv): # create Qt application app = QApplication(argv,True) # create main window wnd = MainWindow() # MainWindow objectname wnd.show() # Connect signal for app finish app.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()")) # Start the app up sys.exit(app.exec_()) if __name__ == "__main__": main(sys.argv)
Initial URL
Initial Description
first design your app and generate a .UI file using Designer (part of Qt Creator), then run pyuic4 to get it to python, like: pyuic4-2.6 example.ui > example.py then import the window classes in example.py and make your up by subclassing like you can see in the source
Initial Title
Qt GUI app in python with pyqt (subclassing pyuic4 generated file)
Initial Tags
python
Initial Language
Python