On Fri, 23 Jul 2004 15:27:33 -0500
Skip Montanaro <[EMAIL PROTECTED]> wrote:
> I like the concept behind the WidgetSaver script Thomas Hinkle posted the
> other day. We're a Glade shop though, so I fear that adding the boilerplate
> necessary to hook up each widget of interest to the WidgetSaver would cause
> a small revolt among the developers. At the very least they'd avoid using
> it for more than toy applications.
>
> So I modified it slightly. ;-) I added a GladeSaverManager class that knows
> how to set up widget saving for a number of widget classes. The full test
> program is now
>
> if gtk.gtk_version < (2, 4):
> print >> sys.stderr, "Need gtk >= 2.4 for this demo (uses gtk.Expander)."
> sys.exit(1)
>
> wtree = gtk.glade.XML("widgetsaver-2.4.glade", 'widgetsaver')
> saver = GladeSaverManager(wtree, ["widgetsaver", "pane", "expander",
> "check", "tog", "spin", "quit"],
> "widgetsaver")
>
> quit = wtree.get_widget("quit")
> quit.connect('clicked', saver.exit)
>
> gtk.main()
> sys.exit(0)
>
> Full details here:
>
> http://www.musi-cal.com/~skip/python/WidgetSaver.py
> http://www.musi-cal.com/~skip/python/widgetsaver-2.4.glade
Very nice. I use glade as well and will implement your improvements shortly -- it's a
much more efficient way to handle setting up multiple savers. In fact, part of me
wants to automate this further -- for example, to hand a class a toplevel widget, and
have all of its descendents given WidgetSavers according to a default-list of
attributes saved for given widgets.
<snip>
> having the saver also
> handle exiting the app seems a bit suspicious.
Indeed. I have windows that load from separate glade files and need to close
themselves without calling main_quit()! There must be a cleaner way to have the
WidgetSaver's save themselves whenever their parent windows are destroyed.
> Skip Montanaro
Tom Hinkle
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/