python - 使文件对话框只接受目录

标签 python qt4 pyqt4 filedialog

我想要一个只允许目录的文件对话框,这是我一直在尝试的:

fileDialog = QtGui.QFileDialog()
fileDialog.setFileMode(QtGui.QFileDialog.ShowDirsOnly)
filename = fileDialog.getOpenFileName(self, 'Select USB Drive Location'))

最佳答案

我想要的是:

directory = QtGui.QFileDialog.getExistingDirectory(self, 'Select USB Drive Location')

关于python - 使文件对话框只接受目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2662527/

相关文章:

c++ - 如何检测丢失的字体字符

python - pyqt4按钮点击处理程序

Python PyQt4 Qpainter 事件消息

python - 如何使用Python GUI自定义按钮和文本框?

python - JSON解码错误: Expecting value: line 1 column 1 (char 0) error in local machine environment but not in server based environment

python - fabric 一直要求输入密码

qt - PySide 插槽不在对象的线程中运行

c++ - QThreads 中断槽和信号

python - PyQt QApplication.aboutToQuit()

python - 获取 matplotlib 直方图函数中的 bin 信息