Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python qt程序错误';MyApp';对象没有属性';用户界面';_Python_Qt_User Interface - Fatal编程技术网

Python qt程序错误';MyApp';对象没有属性';用户界面';

Python qt程序错误';MyApp';对象没有属性';用户界面';,python,qt,user-interface,Python,Qt,User Interface,我已经使用qt designer创建了UI并将代码导出到py,现在我正在尝试连接按钮以添加用户并显示它们,但是我收到了上面的错误,请查看UI代码 # -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'Assignment8.ui' # # Created: Tue Sep 26 11:28:40 2017 # by: PyQt4 UI code generator 4.9.4 # #

我已经使用qt designer创建了UI并将代码导出到py,现在我正在尝试连接按钮以添加用户并显示它们,但是我收到了上面的错误,请查看UI代码

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

# Form implementation generated from reading ui file 'Assignment8.ui'
#
# Created: Tue Sep 26 11:28:40 2017
#      by: PyQt4 UI code generator 4.9.4
#
# WARNING! All changes made in this file will be lost!

from PyQt4 import QtCore, QtGui

try:
    _fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
    _fromUtf8 = lambda s: s

class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName(_fromUtf8("MainWindow"))
        MainWindow.resize(662, 608)
        self.centralwidget = QtGui.QWidget(MainWindow)
        self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
        self.lineResults = QtGui.QLineEdit(self.centralwidget)
        self.lineResults.setGeometry(QtCore.QRect(410, 250, 211, 161))
        self.lineResults.setObjectName(_fromUtf8("lineResults"))
        self.DeleteAll = QtGui.QPushButton(self.centralwidget)
        self.DeleteAll.setGeometry(QtCore.QRect(390, 490, 111, 31))
        self.DeleteAll.setObjectName(_fromUtf8("DeleteAll"))
        self.Delete = QtGui.QPushButton(self.centralwidget)
        self.Delete.setGeometry(QtCore.QRect(270, 490, 111, 31))
        self.Delete.setObjectName(_fromUtf8("Delete"))
        self.Edit = QtGui.QPushButton(self.centralwidget)
        self.Edit.setGeometry(QtCore.QRect(150, 490, 111, 31))
        self.Edit.setObjectName(_fromUtf8("Edit"))
        self.Add = QtGui.QPushButton(self.centralwidget)
        self.Add.setGeometry(QtCore.QRect(20, 490, 111, 31))
        self.Add.setObjectName(_fromUtf8("Add"))
        self.radioButton = QtGui.QRadioButton(self.centralwidget)
        self.radioButton.setGeometry(QtCore.QRect(40, 430, 82, 17))
        self.radioButton.setObjectName(_fromUtf8("radioButton"))
        self.radioButton_2 = QtGui.QRadioButton(self.centralwidget)
        self.radioButton_2.setGeometry(QtCore.QRect(40, 390, 82, 17))
        self.radioButton_2.setObjectName(_fromUtf8("radioButton_2"))
        self.LineDetails = QtGui.QLineEdit(self.centralwidget)
        self.LineDetails.setGeometry(QtCore.QRect(30, 270, 231, 31))
        self.LineDetails.setObjectName(_fromUtf8("LineDetails"))
        self.label = QtGui.QLabel(self.centralwidget)
        self.label.setGeometry(QtCore.QRect(30, 240, 251, 16))
        font = QtGui.QFont()
        font.setPointSize(12)
        self.label.setFont(font)
        self.label.setObjectName(_fromUtf8("label"))
        self.label_3 = QtGui.QLabel(self.centralwidget)
        self.label_3.setGeometry(QtCore.QRect(400, 160, 211, 71))
        font = QtGui.QFont()
        font.setPointSize(12)
        self.label_3.setFont(font)
        self.label_3.setObjectName(_fromUtf8("label_3"))
        self.label_4 = QtGui.QLabel(self.centralwidget)
        self.label_4.setGeometry(QtCore.QRect(430, 210, 111, 16))
        font = QtGui.QFont()
        font.setPointSize(12)
        self.label_4.setFont(font)
        self.label_4.setObjectName(_fromUtf8("label_4"))
        self.label_5 = QtGui.QLabel(self.centralwidget)
        self.label_5.setGeometry(QtCore.QRect(40, 320, 161, 31))
        font = QtGui.QFont()
        font.setPointSize(12)
        self.label_5.setFont(font)
        self.label_5.setObjectName(_fromUtf8("label_5"))
        self.label_2 = QtGui.QLabel(self.centralwidget)
        self.label_2.setGeometry(QtCore.QRect(20, 10, 361, 201))
        self.label_2.setText(_fromUtf8(""))
        self.label_2.setPixmap(QtGui.QPixmap(_fromUtf8("../../../../Users/Rixongile Ndlovu/Desktop/cycle.PNG")))
        self.label_2.setObjectName(_fromUtf8("label_2"))
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtGui.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 662, 21))
        self.menubar.setObjectName(_fromUtf8("menubar"))
        MainWindow.setMenuBar(self.menubar)
        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(QtGui.QApplication.translate("MainWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8))
        self.DeleteAll.setText(QtGui.QApplication.translate("MainWindow", "Delete All", None, QtGui.QApplication.UnicodeUTF8))
        self.Delete.setText(QtGui.QApplication.translate("MainWindow", "Delete", None, QtGui.QApplication.UnicodeUTF8))
        self.Edit.setText(QtGui.QApplication.translate("MainWindow", "Edit", None, QtGui.QApplication.UnicodeUTF8))
        self.Add.setText(QtGui.QApplication.translate("MainWindow", "Add", None, QtGui.QApplication.UnicodeUTF8))
        self.radioButton.setText(QtGui.QApplication.translate("MainWindow", "Female", None, QtGui.QApplication.UnicodeUTF8))
        self.radioButton_2.setText(QtGui.QApplication.translate("MainWindow", "Male", None, QtGui.QApplication.UnicodeUTF8))
        self.label.setText(QtGui.QApplication.translate("MainWindow", "Enter cyclist name and surname", None, QtGui.QApplication.UnicodeUTF8))
        self.label_3.setText(QtGui.QApplication.translate("MainWindow", "List of cyclist registered", None, QtGui.QApplication.UnicodeUTF8))
        self.label_4.setText(QtGui.QApplication.translate("MainWindow", "for the race", None, QtGui.QApplication.UnicodeUTF8))
        self.label_5.setText(QtGui.QApplication.translate("MainWindow", "Select gender", None, QtGui.QApplication.UnicodeUTF8))


if __name__ == "__main__":
    import sys
    app = QtGui.QApplication(sys.argv)
    MainWindow = QtGui.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    MainWindow.show()
    sys.exit(app.exec_())
给我错误的pyw代码,我是否需要为所有对象创建一个单独的类并初始化它们,请帮助

import PyQt4.uic as uic
import sys
from PyQt4 import QtCore, QtGui, uic
qtCreatorFile = "Assignment8.ui"
Ui_MainWindow, QtBaseClass = uic.loadUiType(qtCreatorFile)


class Person(object):
    def __init__(self, first_LastName):
        self.first_LastName = first_LastName

class MyApp(QtGui.QMainWindow, Ui_MainWindow):
    def __init__(self):
        QtGui.QMainWindow.__init__(self)
        Ui_MainWindow.__init__(self)
        self.setupUi(self)
        QtCore.QObject.connect(self.ui.AddButton, QtCore.SIGNAL("Clicked()"), self.addlist)
        QtCore.QObject.connect(self.ui.EditButton, QtCore.SIGNAL("Clicked()"), self.editlist)
        QtCore.QObject.connect(self.ui.DeleteButton, QtCore.SIGNAL("Clicked()"), self.delitem)
        QtCore.QObject.connect(self.ui.ComputeButton, QtCore.SIGNAL("Clicked()"), self.selectitem)
        QtCore.QObject.connect(self.ui.ComputeButton, QtCore.SIGNAL("Clicked()"), self.checkitem)


    def addPerson(self):
        first_LastName = str(self.LineDetails.text())
        self.model.insertRow(p)

    def delitem(self):
        self.ui.listWidget.takeItem(self.ui.ListWidget.currentRow())

    def delallitems(self):
        self.ui.listWidget.clear()


if __name__ == "__main__":
        app = QtGui.QApplication(sys.argv)
        window = MyApp()
        window.show()
        sys.exit(app.exec_())