From 83421848604e6c1f197084c9d46c1b82ed421b20 Mon Sep 17 00:00:00 2001 From: Martin Baeuml Date: Tue, 23 Nov 2010 17:35:46 +0100 Subject: [PATCH] add simple pyqt4 gui --- simple_gui.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 simple_gui.py diff --git a/simple_gui.py b/simple_gui.py new file mode 100755 index 0000000..e6ade43 --- /dev/null +++ b/simple_gui.py @@ -0,0 +1,44 @@ +#!/usr/bin/python +import sys, os +from PyQt4.QtGui import * +from PyQt4.QtCore import * + +class MainWindow(QMainWindow): + def __init__(self, argv, parent=None): + QMainWindow.__init__(self, parent) + + vlayout = QVBoxLayout() + for i in range(5): + button = QPushButton("TestButton %d" % i) + button.clicked.connect(self.clickedButton) + vlayout.addWidget(button) + + hlayout = QHBoxLayout() + self.redlabel = QLabel("mainlabel") + self.redlabel.setStyleSheet("QLabel {background-color: red}") + hlayout.addLayout(vlayout) + hlayout.addWidget(self.redlabel, 1) + + central = QWidget() + central.setLayout(hlayout) + self.setCentralWidget(central) + + def clickedButton(self): + button = self.sender() + print button.text() + self.redlabel.setText(button.text()) + + + + +def main(): + app = QApplication(sys.argv) + + wnd = MainWindow(sys.argv[1:]) + wnd.show() + + return app.exec_() + +if __name__ == '__main__': + sys.exit(main()) +