【发布时间】:2020-05-26 05:30:32
【问题描述】:
我在 UI 中有浏览按钮,单击该按钮会触发打开文件对话框。我的问题是即使在单击浏览按钮之前打开文件对话框也会触发。下面是我的代码
class GisedifySupportDialog(QtWidgets.QDialog, FORM_CLASS):
def __init__(self, parent=None):
"""Constructor."""
super(GisedifySupportDialog, self).__init__(parent)
self.setupUi(self)
self.img_upload=Upload_Image()
self.img_upload.setupUi(self.upload_image_dialog)
self.img_upload.pushButton.clicked.connect(self.browseTheFileAudio(self.img_upload.lineEdit))
def browseTheFileAudio(self,lineedit_name):
self.fileName = QtWidgets.QFileDialog.getOpenFileName(self, "Browse for the file", os.getenv("HOME"))
self.fileName=self.fileName
lineedit_name.setText(str(self.fileName))
return self.fileName
为什么 briwseTheFileAudio 函数在按钮被点击之前就被触发了?
【问题讨论】:
标签: python python-3.x pyqt pyqt5