马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
请问一下,我下面的代码,如果把laber_1注释掉后程序没有报错,但是如果不注释的话
就会报这样的错。请问一下是为什么?应该怎么修改?from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
import sys
class Ui_MainWindow(QMainWindow):
def __init__(self):
super(QtWidgets.QMainWindow,self).__init__()
self.setupUi(self)
self.retranslateUi(self)
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(795, 688)
self.centralWidget = QtWidgets.QWidget(MainWindow)
self.centralWidget.setObjectName("centralWidget")
self.retranslateUi(MainWindow)
self.text_value = QtWidgets.QTextEdit(self.centralWidget)
self.text_value.setGeometry(QtCore.QRect(10, 10, 380, 381))
self.text_value.setObjectName("text_value")
self.label = QtWidgets.QLabel(self.centralWidget)
self.label.setGeometry(QtCore.QRect(400, 10, 380, 381))
self.label.setObjectName("label")
self.label.setText("")
self.label.setStyleSheet("QLabel{background:white;}"
"QLabel{color:rgb(300,300,300,120);font-size:10px;font-weight:bold;font-family:宋体;}"
)
# self.label_1 = QtWidgets.QLabel(self.centralwidget)
# self.label_1.setGeometry(QtCore.QRect(0, 0, 72, 15))
# self.label_1.setObjectName("label_1")
# self.label_1.setText(_translate("MainWindow", "文本显示框:"))
self.tableWidget = QtWidgets.QTableWidget(self.centralWidget)
self.tableWidget.setGeometry(QtCore.QRect(10, 400, 772, 200))
self.tableWidget.setObjectName("tableWidget")
self.tableWidget.setColumnCount(0)
self.tableWidget.setRowCount(0)
self.tableWidget.setStyleSheet("selection-background-color:pink")
self.tableWidget.setEditTriggers(QAbstractItemView.DoubleClicked)
self.tableWidget.raise_()
MainWindow.setCentralWidget(self.centralWidget)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "综合测试平台"))
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
self.label_1 = QtWidgets.QLabel(self.centralwidget) ——>centralwidget的大小写
|