bend or redirect a class method and then call it again

Scott David Daniels Scott.Daniels at Acm.Org
Wed Jul 21 21:21:33 CEST 2004


Franz Steinhaeusler wrote:

> I want to redirect the SetStatusText
> to an own method (change the text somewhat) and
> then call the SetStatusText of wx.Frame.

You are being a bit informal with what is a method and what is a
function.  Your examples don't even parse.  I think this informality
may be the source of your problem.

> class MyFrame (wx.Frame):
> 	def show_status(self):
> 		SetStatusText ("hallo")
> my_frame = Myframe
perhaps you mean:
   my_frame = Myframe()
> Plugin (my_frame)

> def Plugin(frame_inst)
No colon above

> 	#here i want to redirect the setstatustext
> 	setattr(frame_inst, 'SetStatusText', NewStatusText)
You seem to be trying to create a subclass dynamically.

> 	def SetStatusText(te,text,nr=0):
> 			super(MyFrame, MyFrame).SetStatusText("mytext: " + te)
> 			#this is erronous
The super call is being done inside a function, not a class.

> 
> 	
> Is this possible?
> How can I get this working?

Does this address your problem?:

   class MyFrame(wx.Frame):
       def show_status(self):
           SetStatusText("hallo")

       def SetStatusText(self, te, text, nr=0):
           super(MyFrame, self).SetStatusText("mytext: " + te)

-Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Python-list mailing list