Created
March 4, 2013 05:15
-
-
Save evandrix/5080117 to your computer and use it in GitHub Desktop.
PyQt4 + load pyuic4-generated *.ui -> *.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment