0
我已經使用pyuic4將.ui文件轉換爲.py文件。但是當我在python中運行代碼時,什麼都沒有發生。沒有錯誤,沒有用戶界面。代碼運行並在一秒之內結束。我試過使用打印命令進行調試,python沒有進入def setupUi(self, Frame):
或def retranslateUi(self, Frame):
我在做什麼錯?謝謝你的幫助。Python用戶界面不工作。
# -*- 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
我看你已經定義多種功能,但你似乎並沒有叫任何人。記住:除非被調用,否則函數什麼也不做。 – Kevin
你在做什麼錯是沒有閱讀PyQt文檔:例如[使用Qt設計器](http://pyqt.sourceforge.net/Docs/PyQt4/designer.html)。 – ekhumoro