python:Gui错误消息

时间:2016-03-08 16:46:11

标签: python pyside

我尝试学习GUI实现并将我的ui文件包含在我的python脚本中:

from PySide.QtGui import *
import sys
import MultiTool_widget_ui

'''class MainDialog (QDialog, MultiTool_widget_ui.Ui_Form):
    def __init__(self):
        self.setupUi(MainDialog)'''

app = QApplication(sys.argv)
w = MultiTool_widget_ui.Ui_Form()
#w = MainDialog()
w.setupUi(QDialog)
w.show()
app.exec_()

执行,我收到此错误消息:

  

Traceback(最近一次调用最后一次):文件   " C:\ Users \ jhofmann \ workspace \ Testumgebung \ GUI.py",第17行,in          w.setupUi(QDialog)文件" C:\ Users \ jhofmann \ workspace \ Testumgebung \ MultiTool_widget_ui.py",   第14行,在setupUi中       Form.setObjectName(" Form")TypeError:descriptor' setObjectName'需要一个PySide.QtCore.QObject'对象但收到了一个'

指向ui文件中" setupUi" -method中的此代码行:

from PySide import QtCore, QtGui

class Ui_Form(object):
    def setupUi(self, Form):
        Form.setObjectName("Form") <--HERE!
        Form.resize(400, 300)
        self.lcdNumber = QtGui.QLCDNumber(Form)
        self.lcdNumber.setGeometry(QtCore.QRect(0, 110, 64, 23))
        self.lcdNumber.setObjectName("lcdNumber")
        self.pushButton = QtGui.QPushButton(Form)
        self.pushButton.setGeometry(QtCore.QRect(70, 110, 75, 23))
        self.pushButton.setObjectName("pushButton")

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

可能是什么原因?我使用Py 3.4

(评论的块是教程视频中的块)

0 个答案:

没有答案