Closed fuzi1996 closed 7 years ago
Hi @fuzi1996, can you post a full reproducible example so that I can see and test the problem?
Are you sure this relates to this project, and not Qt or PyQt5 in general? This project is about distributing PyQt5 for Windows via pip.
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(400, 300)
Dialog.setSizeGripEnabled(True)
self.pushButton = QtWidgets.QPushButton(Dialog)
self.pushButton.setGeometry(QtCore.QRect(120, 110, 93, 28))
self.pushButton.setObjectName("pushButton")
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.pushButton.setText(_translate("Dialog", "test"))
class Dialog(QDialog, Ui_Dialog):
"""
Class documentation goes here.
"""
def __init__(self, parent=None):
"""
Constructor
@param parent reference to the parent widget
@type QWidget
"""
super(Dialog, self).__init__(parent)
self.setupUi(self)
@pyqtSlot()
def on_pushButton_clicked(self):
"""
Slot documentation goes here.
"""
my_list=[]
my_list.append("aaaa")
my_list.append("cccc")
my_list.append("bbbb")
my_list.append("dddd")
my_str, my_button=QInputDialog.getItem(self, "item","please",my_list)
print(my_button)
print(my_str)
if __name__ == "__main__":
import sys
from PyQt5.QtWidgets import QApplication
app = QApplication(sys.argv)
dlg = Dialog()
dlg.show()
sys.exit(app.exec_())
That is a small example, I mean, when the choice of cancellation, why should return to the string @mottosso
Seeing as this is a question of PyQt5, not python-qt5, I would recommend asking your question on the PyQt5 mailing list.
thanks
When I used PyQt5 to create a drop-down list box,I chose cancle but it still return that str type.I think it should return nothing.