/ Published in: Python
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
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
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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)