How to run a ui converted python file in Qt-Creator



  • I just learned only to convert a qt ui form file into python file by below cmd statement!

    C:\Python27\Lib\site-packages\PyQt4\uic>pyuic4 -o "C:\QT Apps\testApp1\mainwindow.py"
    "C:\QT Apps\testApp1\mainwindow.ui"

    But don't know how to run this converted python file again from Qt creator or from Tk IDE.
    I loaded "mainwindow.py" file into Qt creator using "File->NewFile or Project"
    and tried to run this file using External->Python->RunPy but there is no output!
    Something wrong in I am doing, somebody please help me on what I have to for running this converted py file,
    please note the reference code below

    @

    -- coding: utf-8 --

    Form implementation generated from reading ui file 'C:\QT Apps\testApp1\mainwindow.ui'

    Created: Tue Nov 18 14:35:02 2014

    by: PyQt4 UI code generator 4.11.3

    WARNING! All changes made in this file will be lost!

    from PyQt4 import QtCore, QtGui

    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, MainWindow):
    MainWindow.setObjectName(_fromUtf8("MainWindow"))
    MainWindow.resize(538, 300)
    self.centralWidget = QtGui.QWidget(MainWindow)
    self.centralWidget.setObjectName(_fromUtf8("centralWidget"))
    self.pushButton = QtGui.QPushButton(self.centralWidget)
    self.pushButton.setGeometry(QtCore.QRect(150, 40, 181, 51))
    self.pushButton.setObjectName(_fromUtf8("pushButton"))
    MainWindow.setCentralWidget(self.centralWidget)
    self.menuBar = QtGui.QMenuBar(MainWindow)
    self.menuBar.setGeometry(QtCore.QRect(0, 0, 538, 21))
    self.menuBar.setObjectName(_fromUtf8("menuBar"))
    MainWindow.setMenuBar(self.menuBar)
    self.mainToolBar = QtGui.QToolBar(MainWindow)
    self.mainToolBar.setObjectName(_fromUtf8("mainToolBar"))
    MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.mainToolBar)
    self.statusBar = QtGui.QStatusBar(MainWindow)
    self.statusBar.setObjectName(_fromUtf8("statusBar"))
    MainWindow.setStatusBar(self.statusBar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
    
    def retranslateUi(self, MainWindow):
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None))
        self.pushButton.setText(_translate("MainWindow", " Test QT", None))
    

    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.