#!/usr/bin/env python # -*- coding: utf-8 -*- # Author: Jens Kasten # Date: 20110802 # import os import sys import gettext try: from PyQt4 import QtCore, QtGui except ImportError, e: print str(e) sys.exit() locale_app = sys.argv[0] if locale_app.endswith('.py'): locale_app = locale_app[2:len(locale_app)-3] else: locale_app = locale_app[2:] t = gettext.translation(locale_app, "/usr/share/locale", fallback=True) _ = t.ugettext try: _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: def _fromUtf8(s): return s try: _encoding = QtGui.QApplication.UnicodeUTF8 def _translate(context, text, disambig): return QtGui.QApplication.translate(context, text, disambig, _encoding) except AttributeError: def _translate(context, text, disambig): return QtGui.QApplication.translate(context, text, disambig) class Ui_mainwindow(object): def setupUi(self, Dialog): Dialog.setObjectName(_fromUtf8("Dialog")) Dialog.setGeometry(QtCore.QRect(0, 0, 400, 300)) self.pushButton = QtGui.QPushButton(Dialog) self.pushButton.setGeometry(QtCore.QRect(80, 160, 241, 91)) self.pushButton.setObjectName(_fromUtf8("pushButton")) self.textLabelOUTPUT = QtGui.QLabel(Dialog) self.textLabelOUTPUT.setGeometry(QtCore.QRect(100, 70, 211, 61)) self.textLabelOUTPUT.setObjectName(_fromUtf8("textLabelOUTPUT")) self.retranslateUi(Dialog) QtCore.QMetaObject.connectSlotsByName(Dialog) def retranslateUi(self, Dialog): Dialog.setWindowTitle(_translate("mainwindow", "Dialog", None)) self.pushButton.setText(_translate("mainwindow", "EXECUTE", None)) self.textLabelOUTPUT.setText(_translate("mainwindow", "A", None)) try: _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: def _fromUtf8(s): return s try: _encoding = QtGui.QApplication.UnicodeUTF8 def _translate(context, text, disambig): return QtGui.QApplication.translate(context, text, disambig, _encoding) except AttributeError: def _translate(context, text, disambig): return QtGui.QApplication.translate(context, text, disambig) class Ui_Dialog(object): def setupUi(self, Dialog): Dialog.setObjectName(_fromUtf8("Dialog")) Dialog.resize(400, 300) self.pushButton = QtGui.QPushButton(Dialog) self.pushButton.setGeometry(QtCore.QRect(80, 160, 241, 91)) self.pushButton.setObjectName(_fromUtf8("pushButton")) self.textLabelOUTPUT = QtGui.QLabel(Dialog) self.textLabelOUTPUT.setGeometry(QtCore.QRect(100, 70, 211, 61)) self.textLabelOUTPUT.setObjectName(_fromUtf8("textLabelOUTPUT")) self.retranslateUi(Dialog) QtCore.QMetaObject.connectSlotsByName(Dialog) def retranslateUi(self, Dialog): Dialog.setWindowTitle(_translate("Dialog", "Dialog", None)) self.pushButton.setText(_translate("Dialog", "EXECUTE", None)) self.textLabelOUTPUT.setText(_translate("Dialog", "A", None)) # Don't edit the next class definition and the init method # the need it by the run script for automatic generated code # The attribute ui from MyMainWindow is a convention to the basis working class MyMainWindow(QtGui.QMainWindow): def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.ui = Ui_Dialog() self.ui.setupUi(self) ############################################################################### # start here to insert your code # ############################################################################### if __name__ == "__main__": app = QtGui.QApplication(sys.argv) f = MyMainWindow() f.show() sys.exit(app.exec_())