from login_forma import * import sys app = QtWidgets.QApplication(sys.argv) MainWindow = QtWidgets.QMainWindow() ui = Ui_MainWindow() ui.setupUi(MainWindow) application = Ui_MainWindow() MainWindow.show() login = ui.Login_Edit.text() def on_cliced(): print (login) ui.pushButton.clicked.connect(on_cliced) sys.exit(app.exec())
Суть проблемы: В переменную login пишется пустая строка или если в QT дизайнере задать значение выводится это значение.
файл окна.
from PyQt5 import QtCore, QtGui, QtWidgets class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(800, 381) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.pushButton = QtWidgets.QPushButton(self.centralwidget) self.pushButton.setGeometry(QtCore.QRect(250, 190, 75, 23)) self.pushButton.setObjectName("pushButton") self.Login_Edit = QtWidgets.QLineEdit(self.centralwidget) self.Login_Edit.setGeometry(QtCore.QRect(200, 100, 113, 20)) self.Login_Edit.setObjectName("Login_Edit") 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", "MainWindow")) self.pushButton.setText(_translate("MainWindow", "PushButton")) self.Login_Edit.setText(_translate("MainWindow", "vvvvvv"))