On Fri, Feb 11, 2011 at 3:36 AM, Harold <dadap...@googlemail.com> wrote:
> So, what is the best strategy to use Glade for my controllers while
> retaining separation of control in the program? Are there established
> best practices?

Well, you don't have to pass an object to auto_connect, you can also
pass a dict. This way, you can have separate controller classes, then
you just have to put together a simple dict where the values are
methods bound to whichever controller class you like.

One way to do this could look like this:

class SharedStuff:
    handlers = {}

class DialogAController(SharedStuff)
    def __init__():
        self.handlers['signal-one'] = self.signal_one_handler

class DialogBController(SharedStuff)
    def __init__():
        self.handlers['signal-two'] = self.signal_two_handler

class Application(SharedStuff)
    def __init__():
        self.builder.auto_connect(self.handlers)

This'll work because Python will only create one dictionary, and then
everything that inherits SharedStuff will inherit a reference to the
same dictionary (you might expect that they would inherit new, empty
dictionaries, but they don't), so each class can modify this dict and
all other classes immediately see all the other class's modifications.
_______________________________________________
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