[wxPython-users] How does your application start?

Christopher Barker Chris.Barker at noaa.gov
Mon Apr 23 09:47:45 PDT 2007


James Matthews wrote:
> A common issue!
> 
> The OnInit method calls the super classes __init__ method!

Almost.

This isn't a wx specific issue:

When an object is initialized by Python, it's __init__ method is called. 
The way all attributes are resolved is to first look in the class for 
in, and if there isn't one there, it looks in the superclasses for it. 
So, if you don't define an __init__ in your subclass, the superclass' 
__init__ is called.

That's why you generally need to explicitly call the superclass' 
__init__ when you write your own __init__ -- you're overriding the 
superclass' __init__, so it won't get called if you don't call it.

In the the case of wx.App, I'm pretty sure OnInit() is called in 
wx.App.__init__.

clear as mud?

-Chris

-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov




More information about the wxpython-users mailing list