Posts Tagged ‘python example’

Starting folder in Python’s gtk.FileChooserDialog …

Saturday, October 1st, 2011

I’m at best a knowledgeable beginner in Python but after seeing how badly Bashee Player is at synchronizing your music library with your portable devices, I thought I’d give writing my own synch tool a try…

First hurdle: The starting folder in the gtk.FileChooserDialog as taken from the Ubuntu package “python-gtk2-tutorial”

After reading several pages of documentation, I found a post where a user did something similar and the same worked for the filechooser.py that comes with the examples:

dialog = gtk.FileChooserDialog(“Open..”,
None,
gtk.FILE_CHOOSER_ACTION_OPEN,
(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
gtk.STOCK_OPEN, gtk.RESPONSE_OK))
dialog.set_default_response(gtk.RESPONSE_OK)

dialog.set_current_folder(‘/path/to/your/folder’)

Of course, that’s still hard-coded but if you put in a variable and put the variable into the preferences that the user can edit… voilĂ !

Hope this helps someone!