How to join two fields and a button pyqt5?

0 like 0 dislike
4 views
Good evening. Stupid question. There are 2 fields lineEdit 1/2, there is a button pushButton
I don't quite understand how to make it so that when clicked on pushButton could, for example, output 1 and 2 lineEdit in another function as arguments.
Please tell me
by | 4 views

1 Answer

0 like 0 dislike
import sys from PyQt5.QtWidgets import * from PyQt5.QtCore import * class Example(QMainWindow): send = pyqtSignal(tuple) def __init__(self): super().__init__() self.initUI() @pyqtSlot() def initUI(self): self.setWindowTitle("Example") self.setGeometry(300, 300, 250, 100) self.line_edit = QLineEdit(self) self.line_edit.setGeometry(0, 0, 250, 33) self.line_edit_2 = QLineEdit(self) self.line_edit_2.setGeometry(0, 33, 250, 33) self.button = QPushButton('Start', self) self.button.clicked.connect(self.start) self.button.setGeometry(0, 66, 250, 34) self.send.connect(self.print) def start(self): # print("LineEdit text get:", self.line_edit.text()) # print("LineEdit2 get text:", self.line_edit_2.text()) str_tuple = (self.line_edit.text(), self.line_edit_2.text()) self.send.emit(str_tuple) def print(self, data): print(data) if __name__ == '__main__': application = QApplication(sys.argv) window = Example() window.show() sys.exit(application.exec_())
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
33,907 users