День добрый.
Деплою GUI Приложение на платформе Python с графическим модулем PyQt5.
Откомпилировал приложение в Qt Design.
После отображаются два файла main.py and mydes.py.
Не могу отловить значение получаеммое методом.
text = self.EnterText.text()
Print(text)
Код предоставлю на repl с возможностью редактировать и далее ниже по тексту.
MAIN.py
from PyQt5 import QtWidgets
from mydes import Ui_Form # импорт нашего сгенерированного файла
from PyQt5.QtCore import pyqtSignal, QObject
import sys
class mywindow(QtWidgets.QMainWindow):
def __init__(self):
super(mywindow, self).__init__()
super().__init__()
self.ui = Ui_Form()
self.ui.setupUi(self)
self.ui.BUTTONpush.clicked.connect(self.btnClicked)
text = self.ui.EnterText.text()
def btnClicked(self):
#self.ui.label.setText("Вы нажали на кнопку!")
# Если не использовать, то часть текста исчезнет.
#self.ui.label.adjustSize()
print('Нажали на кнопку' )
print(text, 'введеный текс')
def mostrarFuncion(self):
minombre = self.EnterText.text()
micontrasena = self.contrasena.text()
print("Nombre: " +minombre + " Contrasena: ")
self.setWindowTitle("Nombre: " +minombre + " Contrasena:")
app = QtWidgets.QApplication([])
application = mywindow()
application.show()
sys.exit(app.exec())
mydes.py
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file '1.ui'
#
# Created by: PyQt5 UI code generator 5.13.2
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.setWindowModality(QtCore.Qt.NonModal)
Form.setEnabled(True)
Form.resize(342, 380)
Form.setMinimumSize(QtCore.QSize(342, 380))
Form.setMaximumSize(QtCore.QSize(342, 380))
self.BUTTONpush = QtWidgets.QPushButton(Form)
self.BUTTONpush.setEnabled(True)
self.BUTTONpush.setGeometry(QtCore.QRect(0, 350, 341, 31))
self.BUTTONpush.setObjectName("BUTTONpush")
self.scrollArea = QtWidgets.QScrollArea(Form)
self.scrollArea.setEnabled(True)
self.scrollArea.setGeometry(QtCore.QRect(0, 120, 341, 191))
self.scrollArea.setWidgetResizable(True)
self.scrollArea.setObjectName("scrollArea")
self.scrollAreaWidgetContents = QtWidgets.QWidget()
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 339, 189))
self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")
self.listView = QtWidgets.QListView(self.scrollAreaWidgetContents)
self.listView.setEnabled(True)
self.listView.setGeometry(QtCore.QRect(0, 0, 341, 191))
self.listView.setObjectName("listView")
self.scrollArea.setWidget(self.scrollAreaWidgetContents)
self.EnterText = QtWidgets.QLineEdit(Form)
self.EnterText.setEnabled(True)
self.EnterText.setGeometry(QtCore.QRect(0, 310, 341, 41))
self.EnterText.setObjectName("EnterText")
minombre = self.EnterText.text()
print(minombre)
self.textEdit = QtWidgets.QTextEdit(Form)
self.textEdit.setEnabled(False)
self.textEdit.setGeometry(QtCore.QRect(0, 0, 341, 31))
self.textEdit.setObjectName("textEdit")
self.ProxyInput = QtWidgets.QLineEdit(Form)
self.ProxyInput.setEnabled(True)
self.ProxyInput.setGeometry(QtCore.QRect(60, -1, 281, 31))
self.ProxyInput.setObjectName("ProxyInput")
self.textEdit_2 = QtWidgets.QTextEdit(Form)
self.textEdit_2.setEnabled(False)
self.textEdit_2.setGeometry(QtCore.QRect(0, 30, 341, 31))
self.textEdit_2.setObjectName("textEdit_2")
self.PortInput = QtWidgets.QLineEdit(Form)
self.PortInput.setEnabled(True)
self.PortInput.setGeometry(QtCore.QRect(60, 30, 281, 31))
self.PortInput.setObjectName("PortInput")
self.textEdit_3 = QtWidgets.QTextEdit(Form)
self.textEdit_3.setEnabled(False)
self.textEdit_3.setGeometry(QtCore.QRect(0, 60, 341, 31))
self.textEdit_3.setObjectName("textEdit_3")
self.TokenInput = QtWidgets.QLineEdit(Form)
self.TokenInput.setEnabled(True)
self.TokenInput.setGeometry(QtCore.QRect(60, 60, 281, 31))
self.TokenInput.setObjectName("TokenInput")
self.textEdit_4 = QtWidgets.QTextEdit(Form)
self.textEdit_4.setEnabled(False)
self.textEdit_4.setGeometry(QtCore.QRect(0, 90, 341, 31))
self.textEdit_4.setObjectName("textEdit_4")
self.ChatInput = QtWidgets.QLineEdit(Form)
self.ChatInput.setEnabled(True)
self.ChatInput.setGeometry(QtCore.QRect(60, 90, 281, 31))
self.ChatInput.setObjectName("ChatInput")
self.retranslateUi(Form)
self.BUTTONpush.clicked.connect(self.EnterText.clear)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Chat telegram"))
Form.setToolTip(_translate("Form", "<html><head/><body><p>vd</p></body></html>"))
self.BUTTONpush.setText(_translate("Form", "Send Message"))
self.EnterText.setText(_translate("Form", "text"))
self.textEdit.setHtml(_translate("Form", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-family:\'MS Shell Dlg 2\';\">Proxy</span></p></body></html>"))
self.textEdit_2.setHtml(_translate("Form", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-family:\'MS Shell Dlg 2\';\">Port</span></p></body></html>"))
self.textEdit_3.setHtml(_translate("Form", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-family:\'MS Shell Dlg 2\';\">token</span></p></body></html>"))
self.textEdit_4.setHtml(_translate("Form", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-family:\'MS Shell Dlg 2\';\">chat_id</span></p></body></html>"))