How to invoke parent's method?

rweth rweth at cisco.com
Sun Jan 7 09:51:15 CET 2007


many_years_after wrote:
> Hi, pythoners:
> 
>      My wxPython program includes  a panel whose parent is a frame. The
> panel has a button. When I click the button , I want to let the frame
> destroy. How to implement it? Could the panel invoke the frame's
> method?
> Thanks.
> 
I think it "could" if what I read recently in:
    http://www.python.org/download/releases/2.2/descrintro/#cooperation
Is applicable.

    Look at the link "Cooperative methods and super"
    Write a subclass of panel where the target method of it's parent
    is targX (that parent method of Frame that you want to call)

      class myPanel (Panel):
        def dadsX (self):
           Frame.targX(self)


     I think you are forced to invoke this within a method of the Class
     itself, as opposed to doing so with an instance.

Good luck!





More information about the Python-list mailing list