On Mon, Mar 10, 2003 at 12:54:03PM -0700, Jay Graves wrote:

> I am trying to build an app using an object oriented approach that I saw
> someone post here before.  The code goes something like this

> class GUI(gtk.glade.XML):
>       def __init__(self):
>               gtk.glade.XML.__init__(self,'the.glade.file,'GUI')
>               self.signal_autoconnect(dict(GUI.__dict__))
>               self.textWindow = self.get_widget('textWindow')
>       def on_button_clicked(self):
>               self.textWindow.set_text('this is a test')

I'm not sure I understand the reasoning behind subclassing glade.XML (which
doesn't mean it's a bad idea).

If I already have a widget in the XML tree, my tendency is to use
aggregation rather than subclassing.  For instance, I have a 
MultiColumnTreeView class that takes responsibility for things like adding
columns to the TreeView.  It's not a subclass of TreeView, it just contains
one.  I pass in a TreeView when instantiating a MultiColumnTreeView object.

You can then connect callbacks with something like:

my_widget = xml.get_widget('my_widget')
foo = Foo(my_widget, ...)
xml.signal_autoconnect(foo)

Dave Cook
_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to