После нажатия на кнопку, текст, который должен отобразиться в label
залазит на кнопку.
Код:
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(268, 310)
MainWindow.setMinimumSize(QtCore.QSize(268, 310))
MainWindow.setMaximumSize(QtCore.QSize(268, 310))
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.plainTextEdit = QtWidgets.QPlainTextEdit(self.centralwidget)
self.plainTextEdit.setGeometry(QtCore.QRect(10, 10, 251, 211))
self.plainTextEdit.setObjectName("plainTextEdit")
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(10, 260, 251, 41))
self.pushButton.setMinimumSize(QtCore.QSize(251, 41))
self.pushButton.setMaximumSize(QtCore.QSize(251, 41))
self.pushButton.setObjectName("pushButton")
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(10, 280, 251, 21))
self.label.setText("")
self.label.setObjectName("label")
MainWindow.setCentralWidget(self.centralwidget)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.plainTextEdit.setPlaceholderText(_translate("MainWindow", "Лог..."))
self.pushButton.setText(_translate("MainWindow", "PushButton"))
class MyWin(QtWidgets.QMainWindow):
def __init__(self, parent = None):
QtWidgets.QWidget.__init__(self, parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.ui.pushButton.clicked.connect(self.handler)
def handler(self):
self.ui.pushButton.setDisabled(True)
self.ui.plainTextEdit.appendPlainText('Push')
self.ui.label.setText('Push')
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
myapp = MyWin()
myapp.show()
sys.exit(app.exec_())