Используя, дизайн, созданный в QT 5 designer, и наследуя его в собственном классе ловлю ошибку того, что мой класс не имеет функции, которая есть в design_login.py
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(229, 317)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget)
self.verticalLayout.setObjectName("verticalLayout")
self.labelHost = QtWidgets.QLabel(self.centralwidget)
self.labelHost.setObjectName("labelHost")
self.verticalLayout.addWidget(self.labelHost)
self.lineEditHost = QtWidgets.QLineEdit(self.centralwidget)
self.lineEditHost.setObjectName("lineEditHost")
self.verticalLayout.addWidget(self.lineEditHost)
self.labelPort = QtWidgets.QLabel(self.centralwidget)
self.labelPort.setObjectName("labelPort")
self.verticalLayout.addWidget(self.labelPort)
self.lineEditPort = QtWidgets.QLineEdit(self.centralwidget)
self.lineEditPort.setObjectName("lineEditPort")
self.verticalLayout.addWidget(self.lineEditPort)
self.labelLogin = QtWidgets.QLabel(self.centralwidget)
self.labelLogin.setObjectName("labelLogin")
self.verticalLayout.addWidget(self.labelLogin)
self.lineEditLogin = QtWidgets.QLineEdit(self.centralwidget)
self.lineEditLogin.setObjectName("lineEditLogin")
self.verticalLayout.addWidget(self.lineEditLogin)
self.labelPassword = QtWidgets.QLabel(self.centralwidget)
self.labelPassword.setObjectName("labelPassword")
self.verticalLayout.addWidget(self.labelPassword)
self.lineEditPassword = QtWidgets.QLineEdit(self.centralwidget)
self.lineEditPassword.setObjectName("lineEditPassword")
self.verticalLayout.addWidget(self.lineEditPassword)
self.ButtonConnect = QtWidgets.QPushButton(self.centralwidget)
self.ButtonConnect.setObjectName("ButtonConnect")
self.verticalLayout.addWidget(self.ButtonConnect)
MainWindow.setCentralWidget(self.centralwidget)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "Login window"))
self.labelHost.setText(_translate("MainWindow", "Host address"))
self.labelPort.setText(_translate("MainWindow", "Port"))
self.labelLogin.setText(_translate("MainWindow", "Login"))
self.labelPassword.setText(_translate("MainWindow", "Password"))
self.ButtonConnect.setText(_translate("MainWindow", "Connect"))
-----------------------------------------------------------------------------------------------------------------------------------
GUI_login.py
from PyQt5 import QtWidgets as qtw
import design_login
import Connection
import sys
class GUI(qtw.QMainWindow, design_login.Ui_MainWindow):
Host = " "
Port = 9090
login = " "
password = " "
def __init__(self):
super().__init__()
self.setupUI(self)
self.lineEditPassword.Password()
self.ButtonConnect.clicked.connect(self.read_n_connect())
def read_n_connect(self):
Host = self.lineEditHost.text()
Port = self.lineEditPort.text()
login = self.lineEditLogin.text()
password = self.lineEditPassword.text()
client = Connection.Client(Host, Port, login, password)
if __name__ == '__main__':
app = qtw.QApplication(sys.argv)
ex = GUI()
ex.show()
sys.exit(app.exec_())
ошибка:
Traceback (most recent call last):
File "/home/lrxz/PycharmProjects/Client/GUI_login.py", line 29, in
ex = GUI()
File "/home/lrxz/PycharmProjects/Client/GUI_login.py", line 15, in __init__
self.setupUI(self)
AttributeError: 'GUI' object has no attribute 'setupUI'
Process finished with exit code 1