From 9d5ce4424662167e65396cdfb4baaeeb59958d6f Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Mon, 18 Dec 2006 19:32:23 +0000 Subject: [PATCH] Added widget to OptionsBox, which lets the user choose a file using a GtkFileChooser or by drag-and-drop (Jim Ramsay). Requires GTK >= 2.6. git-svn-id: https://rox.svn.sourceforge.net/svnroot/rox/trunk/rox-lib@4886 66de3db3-b00d-0410-b41b-f4738ad19bea --- ROX-Lib2/python/rox/OptionsBox.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/ROX-Lib2/python/rox/OptionsBox.py b/ROX-Lib2/python/rox/OptionsBox.py index d259fda..2ca3eb2 100644 --- a/ROX-Lib2/python/rox/OptionsBox.py +++ b/ROX-Lib2/python/rox/OptionsBox.py @@ -580,6 +580,27 @@ class OptionsBox(g.Dialog): return [hbox] + def build_filechooser(self, node, label, option): + """Tooltip. + Lets the user choose a file (using a GtkFileChooser or by drag-and-drop). + Note: requires GTK >= 2.6 + """ + filebutton = g.FileChooserButton(label) + eb = g.EventBox() + eb.add(filebutton) + self.may_add_tip(eb, node) + if label: + hbox = g.HBox(False, 4) + hbox.pack_start(g.Label(label + ":"), False, True, 0) + hbox.pack_start(eb, True, True, 0) + else: + hbox = None + self.handlers[option] = ( + lambda: filebutton.get_filename(), + lambda: filebutton.set_filename(option.value)) + filebutton.connect('selection-changed', lambda w: self.check_widget(option)) + return [hbox or eb] + def build_menu(self, node, label, option): """Build an OptionMenu widget, only one item of which may be selected. -- 2.11.4.GIT