wx.filedialog
Python hosting: Host, run, and code Python in the cloud!
Nearly every desktop application that can open one or more files has a file dialog.
An open file dialog may seem like a very complicated window to create: it contains buttons, locations, labels and many more widgets. Moreover, the appearance of this open file dialog looks different on every platform: Mac OS, Windows and so on.
Related course: Creating GUI Applications with wxPython
The wxPython module comes with open file dialogs, which can be created with a few functions calls.

wxPython file dialog
The example below creates a file dialog with a native appearance using wxPython:
#!/usr/bin/python |
To create a file dialog with wxPython we can simply call wx.FileDialog().
The definition of this method is: (parent, message, defaultDir, defaultFile, wildcard, style, pos)
We call this method with the arguments:
|
(no default dir or default file is specified).
The method showModal() displays the window:
|
The command openFileDialog.GetPath() returns the full path to the file if one is selected.
Related course: Creating GUI Applications with wxPython
Leave a Reply: