【发布时间】:2019-05-07 09:14:03
【问题描述】:
我想在 PyQt5.QtWidgets QInputDialog 中从用户那里获得多个输入文本...在这段代码中,我只能获得一个输入文本框,当我单击按钮时我想获得更多输入文本框。查看图片了解更多信息...
from PyQt5.QtWidgets import (QApplication,QWidget,QPushButton,QLineEdit,QInputDialog,QHBoxLayout)
import sys
class FD(QWidget):
def __init__(self):
super().__init__()
self.mysf()
def mysf(self):
hbox = QHBoxLayout()
self.btn = QPushButton('ClickMe',self)
self.btn.clicked.connect(self.sd)
hbox.addWidget(self.btn)
hbox.addStretch(1)
self.le = QLineEdit(self)
hbox.addWidget(self.le)
self.setLayout(hbox)
self.setWindowTitle("InputDialog")
self.setGeometry(300,300,290,150)
self.show()
def sd(self):
text , ok = QInputDialog.getText(self,'InputDialog','EnterYourName = ')
if ok:
self.le.setText(str(text))
if __name__ == '__main__':
app = QApplication(sys.argv)
F = FD()
sys.exit(app.exec_())
【问题讨论】:
标签: python python-3.x pyqt pyqt5