0

I have converted .ui file to .py file using pyuic4. But when I run the code in python nothing is happening. No errors, no user interface. The code runs and ends within a second. I tried debugging using print command, python is not entering within def setupUi(self, Frame): or def retranslateUi(self, Frame): What am I doing wrong? Thanks for your help.

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'web.ui'
#
# Created: Mon Dec 29 08:39:41 2014
#      by: PyQt4 UI code generator 4.11.3
#
# WARNING! All changes made in this file will be lost!

from PyQt4 import QtCore, QtGui
import sys

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_Frame(object):
    def setupUi(self, Frame):
        Frame.setObjectName(_fromUtf8("Frame"))
        Frame.resize(562, 525)
        Frame.setFrameShape(QtGui.QFrame.StyledPanel)
        Frame.setFrameShadow(QtGui.QFrame.Raised)
        self.webView = QtWebKit.QWebView(Frame)
        self.webView.setGeometry(QtCore.QRect(0, 60, 561, 461))
        self.webView.setUrl(QtCore.QUrl(_fromUtf8("about:blank")))
        self.webView.setObjectName(_fromUtf8("webView"))
        self.pushButton = QtGui.QPushButton(Frame)
        self.pushButton.setGeometry(QtCore.QRect(460, 20, 75, 23))
        self.pushButton.setObjectName(_fromUtf8("pushButton"))
        self.lineEdit = QtGui.QLineEdit(Frame)
        self.lineEdit.setGeometry(QtCore.QRect(70, 30, 351, 20))
        self.lineEdit.setObjectName(_fromUtf8("lineEdit"))

        self.retranslateUi(Frame)
        QtCore.QMetaObject.connectSlotsByName(Frame)

    def retranslateUi(self, Frame):
        Frame.setWindowTitle(_translate("Frame", "Frame", None))
        self.pushButton.setText(_translate("Frame", "PushButton", None))

from PyQt4 import QtWebKit
h P
  • 1
  • 1
    I see you have defined several functions, but you don't seem to call any of them. Remember: functions do nothing unless they're called. – Kevin Dec 29 '14 at 15:17
  • What you are doing wrong is failing to read the PyQt documentation: e.g. [Using Qt Designer](http://pyqt.sourceforge.net/Docs/PyQt4/designer.html). – ekhumoro Dec 29 '14 at 21:20

1 Answers1

0

Add this:

if __name__ == "__main__":
   app = QtGui.QApplication(sys.argv)
   f=QtGui.QMainWindow()
   w = Ui_MainWindow()

   w.setupUi(f)
   f.show()
   sys.exit(app.exec_())
Timo Junolainen
  • 294
  • 2
  • 13