On Fri, May 13, 2005 at 01:23:14PM -0600, Pete Nagy wrote: > I am having trouble porting an application from gtk1.2 to gtk2. I have > a c module with subclasses with corresponding python wrapper classes.
I know exactly what you mean. This is one of the consequences of the "wrapping model" having changed with PyGTK-2. > The python classes could add extra code to the wrapped c module classes, > and you could create a new C object by simply assigning an instance of > _m.c to the ._o in the C instance, and then with the C instance you could > call all _m.c functions as well as the additional methods added at the > pure python level in classes C, B or A. Yes, but this also resulted in some unexpected behaviour: the widget wrapper received in a callback would be of the "original" type, and there was overhead for just instantiating all these Python wrappers. The new model is a bit less flexible but "more correct". I'm totally the "quotes guy" today! > What I really want is to replicate what was possible with the old > pygtk, which is create a new instance of B at the python level that > wraps the _m.b instance, so that calls to functions in B are really > calls to the underlying _m.b instance. Why not implement the wrapper and proxy yourself, using something like a special __getattr__ hook that passes calls to the underlying GtkObject? It's not a complete solution, but it may work in your case. > I have tried having the B(_m.b, A) __init__ method take an _m.b > parameter, and if specified then I bypass the _m.b init call (which would > create a second instance of _m.b, which would be bad), and instead assign > the _m.b instance to a ._o attribute, and I modifiy __getattribute__ to > pass any calls to the ._o, if it exists. This works in that I can call > _m.b methods using the B object, but not all of the magic is working, > as B is not considered an initialized instance of _m.b, and these gtk > widgets don't display properly. Hmmm. Too many underscores for me to grok in these 30 seconds. Why do you need to inherit from _m.b? Simple composition should work for the simpler cases, shouldn't it? Take care, -- Christian Robottom Reis | http://async.com.br/~kiko/ | [+55 16] 3376 0125 _______________________________________________ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/