Jun-23-2020, 08:41 AM
Dear all,
This is one example that I copy from a website.
I wish to duplicate the row without duplicating like name1, name 2 in the code and show in GUI.
I want initial with one row. But with add or remove button, I can simply duplicate or remove the row.
May I get some hints from you guys.
Thanks.
This is one example that I copy from a website.
I wish to duplicate the row without duplicating like name1, name 2 in the code and show in GUI.
I want initial with one row. But with add or remove button, I can simply duplicate or remove the row.
May I get some hints from you guys.
Thanks.
import sys from PySide2 import QtCore, QtWidgets from PySide2.QtWidgets import QMainWindow, QWidget, QLabel, QLineEdit from PySide2.QtWidgets import QPushButton from PySide2.QtCore import QSize class MainWindow(QMainWindow): def __init__(self): QMainWindow.__init__(self) self.setMinimumSize(QSize(320, 140)) self.setWindowTitle("PyQt Line Edit example (textfield) - pythonprogramminglanguage.com") self.nameLabel = QLabel(self) self.nameLabel.setText('Name:') self.line = QLineEdit(self) self.line.move(80, 20) self.line.resize(200, 32) self.nameLabel.move(20, 20) pybutton = QPushButton('OK', self) pybutton.clicked.connect(self.clickMethod) pybutton.resize(200,32) pybutton.move(80, 60) def clickMethod(self): print('Your name: ' + self.line.text()) if __name__ == "__main__": app = QtWidgets.QApplication(sys.argv) mainWin = MainWindow() mainWin.show() sys.exit(app.exec_())