Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a file browser in wxpython

I am developing the GUI for my application using wxpython and have most of the features down, except in the main frame/window I want to have a box for choosing a file (in this case, the input will have to be an excel file). Something similar to the standard filebrowser that is accessed whenever you choose "open" from a menu. Below is an image to show exactly what I want...

enter image description here

like image 463
ohbrobig Avatar asked Sep 06 '26 13:09

ohbrobig


1 Answers

You probably want a wx.FileDialog. It provides access to the default file dialog of the OS your app is running in. You can see an example of how it's used in the wxPython demo package. This tutorial also has some screenshots and sample code:

  • http://www.blog.pythonlibrary.org/2010/06/26/the-dialogs-of-wxpython-part-1-of-2/

The screenshot you show appears to be an interface to actually open the dialog. You can easily create that using sizers and basic widgets. Then just bind the open button to a handler that will show the dialog.

You might also want to take a look at the FileBrowseButton from wx.lib.filebrowsebutton (also in the demo).

There are a few other related widgets which you might be interested in too: wx.DirDialog, MultiDirDialog or wx.GenericDirDialog.

like image 131
Mike Driscoll Avatar answered Sep 08 '26 04:09

Mike Driscoll



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!