I've got a wx.FileDialog()
that currently accepts .zip, .litemod, and .jar (*.zip;*.litemod;*.jar
). How can I change this to also accept directories? I would normally think *.zip;*.litemod;*.jar;*
, but this would just allow all files.

- 15,602
- 32
- 87
- 122
1 Answers
You mean you would like to be able to choosing either file or directory from FileDialog
? I doubt it is possible (at least couldn't find anything about such possibility in docs). If it would be possible, how should dialog determine whether you want to choose or just enter the directory when you double-click the directory?
There is special dialog type that allows to choose directories: DirDialog. It doesn't allow to select files, though.
UPDATE:
Please, look at this thread. As one of users write:
If you want a file then use wx.FileDialog. If you want a folder then use wx.DirDialog. That's why there are two different classes. If you must be able to select either from the same dialog then you'll need to create your own.
But last answer shows simple implementation of custom dialog. Maybe it will be helpful to you.

- 6,443
- 7
- 47
- 70
-
1I've seen this done before. If you double click on the directory it goes into the directory, but if you press enter in the directory without selecting something, or you single-click the directory and press enter, it chooses the directory. – tkbx Nov 02 '12 at 13:59
-
Actually, the user @Piotr refers to is a wxPython developer / creator. If he says you have to create your own dialog to handle this, he is probably right. You may have seen it done before, but that does not mean that it is already existing dialog. Someone just wrote their own. – Fenikso Jan 04 '13 at 08:52
-
@Fenikso so how would someone go about making one? – tkbx Jan 04 '13 at 14:15
-
1Robin Dunn is the creator of wxPython, so yeah, he's probably right. If you want to create a custom dialog, you'll want wx.Dialog. You should take a look at GenericDirCtrl of MultiDirDialog to see examples of generic dialogs that are similar to what you want. – Mike Driscoll Jan 04 '13 at 20:50
-
1First, I would ask myself if that is really necessary. If I were you I would just create two buttons, with "Select File" and "Select Directory" labels. If you think that would break user experience, then go with Mike's recommendation. – Fenikso Jan 07 '13 at 12:26