import sys
from PyQt5.QtWidgets import *
class Example(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle("Пример")
self.textEdit = QTextEdit(self)
self.textEdit.toPlainText()
self.pushButton = QPushButton('ok', self)
self.pushButton.move(50, 50)
self.pushButton.clicked.connect(click)
def click(self):
text = self.textEdit.toPlainText()
print(text)
if __name__ == '__main__':
app = QApplication(sys.argv)
form = Example()
form.show()
app.exec()
import sys
from PyQt5.QtWidgets import *
class Example(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle("Пример")
self.grid_layout = QGridLayout()
self.setLayout(self.grid_layout)
self.textEdit = QTextEdit(self)
self.textEdit.toPlainText()
self.pushButton = QPushButton('ok', self)
self.pushButton.move(50, 50)
self.pushButton.clicked.connect(self.pushButtonClickedHandler)
self.grid_layout.addWidget(self.textEdit, 0, 0)
self.grid_layout.addWidget(self.pushButton)
def pushButtonClickedHandler(self):
text = self.textEdit.toPlainText()
self.grid_layout.addWidget(QLabel(text = text))
if __name__ == '__main__':
app = QApplication(sys.argv)
form = Example()
form.show()
app.exec()