rweth wrote: > 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! > > You know I just tried a code fragment and got the parent method to work with an instance .. so maybe you don't have to subclass. Here is a transcript illustrating the idea:
>>> class DAD: ... def methodx(self): ... print "DAD-methodx" ... >>> class SON(DAD): ... def methodx(self): ... print "SON-methodx" ... >>> >>> >>> billy = SON() >>> billy.methodx() SON-methodx >>> DAD.methodx(billy) DAD-methodx >>> So you can invoke the DAD.methodx via the billy instance of the object .. without subclassing. Now I wonder if this will actually work? -- http://mail.python.org/mailman/listinfo/python-list