[wxPython-users] Init Question
Christopher Barker
Chris.Barker at noaa.gov
Thu Feb 22 17:02:08 PST 2007
Telly Williams wrote:
> --------------------------------
> class MyTreeCtrl(wx.TreeCtrl):
> def __init__(self, parent, id, pos, size, style, log):
> wx.TreeCtrl.__init__(self, parent, id, pos, size, style)
> --------------------------------
>
> I still can't understand why you instantiate the wx.TreeCtrl (or any
> other object, for that matter), def __init__ the TreeCtrl, and then
> __init__ it again. What's with initiating it twice? It was already
> done, right? Thank you.
This is very standard subclassing in Python. You need to manually call
the superclass' __init__ if you want it to run. Otherwise, your __init__
has over-ridden the superclass' one, so it will never get called.
If there is nothing to be done in the subclass __init__, you can not
define one, and then the superclass' one will get called.
You really need to understand OO in Python to be able to use wxPython:
Note that the first entry in:
http://wiki.wxpython.org/index.cgi/How_to_Learn_wxPython
is: "Learn Python"
-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