wwwookie
March 11th, 2011, 12:05 AM
Hi,
I've been using the python gtk.FileChooserButton widget to select files as part of a gui I'm writing, and everything works fine. However, when I try to use the same widget to select directories, I get a combobox that I didn't ask for with all my nautilus bookmarks in it and 'other' at the bottom of the list. If I select 'other', I then get to the filechooser window I originally wanted.
Here's a miniature example to show what I mean.
import pygtk
pygtk.require('2.0')
import gtk
class Base:
def delete_event(self, widget, event, data = None):
return False
def destroy(self, widget, data = None):
gtk.main_quit()
def __init__(self):
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.connect("delete_event", self.delete_event)
self.window.connect("destroy", self.destroy)
self.window.set_border_width(10)
# this is the bit I'm talking about
button=gtk.FileChooserButton('Select Directory')
button.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_F OLDER)
self.window.add(button)
button.show()
self.window.show()
def main(self):
gtk.main()
if __name__ == "__main__":
base = Base()
base.main()Is there anyway I can disable this combobox and go straight to the filechooser? It seems there should be a way, it's easy in bash:-
zenity --file-selection --directory
Please tell me I'm doing something wrong and there's a really easy fix!
I've been using the python gtk.FileChooserButton widget to select files as part of a gui I'm writing, and everything works fine. However, when I try to use the same widget to select directories, I get a combobox that I didn't ask for with all my nautilus bookmarks in it and 'other' at the bottom of the list. If I select 'other', I then get to the filechooser window I originally wanted.
Here's a miniature example to show what I mean.
import pygtk
pygtk.require('2.0')
import gtk
class Base:
def delete_event(self, widget, event, data = None):
return False
def destroy(self, widget, data = None):
gtk.main_quit()
def __init__(self):
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.connect("delete_event", self.delete_event)
self.window.connect("destroy", self.destroy)
self.window.set_border_width(10)
# this is the bit I'm talking about
button=gtk.FileChooserButton('Select Directory')
button.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_F OLDER)
self.window.add(button)
button.show()
self.window.show()
def main(self):
gtk.main()
if __name__ == "__main__":
base = Base()
base.main()Is there anyway I can disable this combobox and go straight to the filechooser? It seems there should be a way, it's easy in bash:-
zenity --file-selection --directory
Please tell me I'm doing something wrong and there's a really easy fix!