0
0 комментариев

Вопрос по Pqt5 (python 3.7)- Как вывести в ячейке tableWidget (расположенного на mainWindows) виджет с набором label … и пр. элементов

Привожу код, вываливается в строке «form_temp.setObjectName(«form_temp»)» с ошибкой.

с ошибкой

File «E:\webdisk\google\rabota2020\rahib\electro03022020\left_big.py», line 15, in setupUi
form_temp.setObjectName(«form_temp»)
AttributeError: ‘Ui_form_temp’ object has no attribute ‘setObjectName’

Прошу помочь!!!


import sys
from PyQt5.QtWidgets import *
  class Electro(QMainWindow):
    def __init__(self):
        super(Electro, self).__init__()
        self.ui=Ui_MainWindow()
        self.ui.setupUi(self)
        pogoda1=Ui_form_temp()
        pogoda1.setupUi(pogoda1)
        self.ui.tableWidget.setCellWidget(1,1,pogoda1)
        self.show()
 class Ui_form_temp(object):
    def setupUi(self, form_temp):
        form_temp.setObjectName("form_temp")
        form_temp.resize(279, 273)
        self.timeLable = QtWidgets.QLabel(form_temp)
        self.timeLable.setGeometry(QtCore.QRect(10, 40, 81, 21))
        font = QtGui.QFont()
        font.setPointSize(16)
        font.setBold(False)
        font.setWeight(50)
        self.timeLable.setFont(font)
        self.timeLable.setObjectName("timeLable")
        self.label_gradus = QtWidgets.QLabel(form_temp)
        self.label_gradus.setGeometry(QtCore.QRect(30, 70, 121, 61))
        font = QtGui.QFont()
        font.setPointSize(29)
        self.label_gradus.setFont(font)
        self.label_gradus.setObjectName("label_gradus")
        self.label_3 = QtWidgets.QLabel(form_temp)
        self.label_3.setGeometry(QtCore.QRect(10, 150, 141, 16))
        font = QtGui.QFont()
        font.setPointSize(11)
        self.label_3.setFont(font)
        self.label_3.setObjectName("label_3")
        self.label_4 = QtWidgets.QLabel(form_temp)
        self.label_4.setGeometry(QtCore.QRect(20, 170, 251, 21))
        font = QtGui.QFont()
        font.setPointSize(15)
        font.setBold(True)
        font.setWeight(75)
        self.label_4.setFont(font)
        self.label_4.setObjectName("label_4")
        self.label = QtWidgets.QLabel(form_temp)
        self.label.setGeometry(QtCore.QRect(11, 200, 121, 16))
        font = QtGui.QFont()
        font.setPointSize(11)
        self.label.setFont(font)
        self.label.setObjectName("label")
        self.label_2 = QtWidgets.QLabel(form_temp)
        self.label_2.setGeometry(QtCore.QRect(20, 220, 151, 21))
        font = QtGui.QFont()
        font.setPointSize(15)
        font.setBold(True)
        font.setWeight(75)
        self.label_2.setFont(font)
        self.label_2.setObjectName("label_2")
         self.retranslateUi(form_temp)
        QtCore.QMetaObject.connectSlotsByName(form_temp)
     def retranslateUi(self, form_temp):
        _translate = QtCore.QCoreApplication.translate
        form_temp.setWindowTitle(_translate("form_temp", "Form"))
        self.timeLable.setText(_translate("form_temp", "09:17"))
        self.label_gradus.setText(_translate("form_temp", "+6 C"))
        self.label_3.setText(_translate("form_temp", "Havanın durumu: "))
        self.label_4.setText(_translate("form_temp", "QISMƏN BULUDLU "))
        self.label.setText(_translate("form_temp", "Küləyin sürəti:"))
        self.label_2.setText(_translate("form_temp", "3-8 m/s"))
  class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(843, 711)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget)
        self.verticalLayout.setObjectName("verticalLayout")
        self.verticalLayout_2 = QtWidgets.QVBoxLayout()
        self.verticalLayout_2.setObjectName("verticalLayout_2")
        self.tabWidget = QtWidgets.QTabWidget(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.tabWidget.sizePolicy().hasHeightForWidth())
        self.tabWidget.setSizePolicy(sizePolicy)
        self.tabWidget.setObjectName("tabWidget")
        self.tab = QtWidgets.QWidget()
        self.tab.setObjectName("tab")
        self.tabWidget.addTab(self.tab, "")
        self.tab_2 = QtWidgets.QWidget()
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.tab_2.sizePolicy().hasHeightForWidth())
        self.tab_2.setSizePolicy(sizePolicy)
        self.tab_2.setMaximumSize(QtCore.QSize(770, 337))
        self.tab_2.setObjectName("tab_2")
        self.tableWidget = QtWidgets.QTableWidget(self.tab_2)
        self.tableWidget.setGeometry(QtCore.QRect(10, 10, 791, 361))
        self.tableWidget.setRowCount(4)
        self.tableWidget.setColumnCount(2)
        self.tableWidget.setObjectName("tableWidget")
        item = QtWidgets.QTableWidgetItem()
        self.tableWidget.setItem(0, 0, item)
        item = QtWidgets.QTableWidgetItem()
        self.tableWidget.setItem(0, 1, item)
        item = QtWidgets.QTableWidgetItem()
        self.tableWidget.setItem(1, 0, item)
        item = QtWidgets.QTableWidgetItem()
        self.tableWidget.setItem(1, 1, item)
        self.tableWidget.horizontalHeader().setCascadingSectionResizes(False)
        self.tableWidget.horizontalHeader().setDefaultSectionSize(300)
        self.tabWidget.addTab(self.tab_2, "")
        self.verticalLayout_2.addWidget(self.tabWidget)
        self.verticalLayout.addLayout(self.verticalLayout_2)
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 843, 26))
        self.menubar.setObjectName("menubar")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)
         self.retranslateUi(MainWindow)
        self.tabWidget.setCurrentIndex(1)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
     def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), _translate("MainWindow", "Tab 1"))
        __sortingEnabled = self.tableWidget.isSortingEnabled()
        self.tableWidget.setSortingEnabled(False)
        item = self.tableWidget.item(0, 0)
        item.setText(_translate("MainWindow", "гнпгнп"))
        item = self.tableWidget.item(0, 1)
        item.setText(_translate("MainWindow", "лорлорол"))
        item = self.tableWidget.item(1, 0)
        item.setText(_translate("MainWindow", "ыкпукрпкаивмпывуыуваыупыкпеуыеупуыеу"))
        item = self.tableWidget.item(1, 1)
        item.setText(_translate("MainWindow", "рчарркрк"))
        self.tableWidget.setSortingEnabled(__sortingEnabled)
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), _translate("MainWindow", "Tab 2"))
     def main():
    app = QApplication(sys.argv)
    ex = Electro()
    sys.exit(app.exec_())
  if __name__ == '__main__':
    main()

                                    
Добавить комментарий