Thanks. I'll use that aproach. I saw a lot of self.wTree's so I'll stick with 
that naming convention.

Regards,
Leon

________________________________________
From: Pietro Battiston [...@pietrobattiston.it]
Sent: Monday, December 06, 2010 09:31
To: Leon Bogaert
Cc: marco.giu...@gmail.com; pygtk@daa.com.au
Subject: Re: [pygtk] self from gtk.builder

Il giorno lun, 06/12/2010 alle 00.28 +0000, Leon Bogaert ha scritto:
> Thanks Marco,
>
> Messing with __getattr__... I think I'm going to let that pass. It feels 
> kinda messy.
> I'm just begining with gtk and I've been browsing through other people's code 
> but I find it difficult to organize my gtk code.
>

Anyway, the main message is: if you must use a widget created through a
glade file, you can live without subclassing it. For the "ordinary"
operations, you can just do

class ActionsMenu(object):
    def __init__(self, widget):
        self.widget = widget

and then access the "widget" argument when you need it; if instead you
have to override some method, you can do

class ActionsMenu(object):
    def __init__(self, widget):
        self.widget = widget
        self.widget.do_size_request = my_newly_written_size_request


My personal (and not particularly authoritative) impression is that
while in the traditional pygtk approach you (grossly speaking) create a
subclass for each "important" widget in your app, when you use
glade/gtk.Builder you just create subclasses for "conceptually
important" objects, which may then be related to (and have as members)
0, 1, or many widgets each. And that this is, in the end, the
traditional way to organize Python code.


Pietro

_______________________________________________
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to