views:

237

answers:

2

I want to have a file dialog only allow directories, here's what I've been trying:

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

Thank You

+1  A: 

The Qt 4.6 docs for ShowDirsOnly says:

"Only show directories in the file dialog. By default both files and directories are shown. (Valid only in the Directory file mode.)"

Maybe it isn't in "Directory" file mode?

bde
+1  A: 

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

is what I wanted.

matt