bend or redirect a class method and then call it again

Jeff Shannon jeff at ccvcorp.com
Fri Jul 23 16:45:07 EDT 2004


Franz Steinhaeusler wrote:

>On Thu, 22 Jul 2004 14:24:28 -0700, Jeff Shannon <jeff at ccvcorp.com>
>wrote:
>
>  
>
>>Unless I'm misunderstanding your intent, then yes, from drFrame itself.
>>
>>Every Plugin object is also a drFrame object (and a wx.Frame object).  
>>    
>>
>
>No. Plugin is a *function*, which receives a *drFrame object*.
>It should have the purpose to "redirect" all the SetStatusText 
>calls from within drFrame.
>  
>

Ah, well, then I *was* misunderstanding -- I'm not sure how I became 
convinced that Plugin was a derived class, but convinced I was, and 
built all further opinions on top of that false conviction.

I'd say that if you want a function to alter the behavior of all objects 
of a particular class, it's probably better to have some sort of flag as 
a class variable, and have your function set that flag rather than 
rebind a method.  I'd still be inclined to think that this should be 
done on a per-instance basis, rather than for the entire class, but I 
can see some case to be made for changing the entire class, too.

Perhaps you can define a StatusTextFormat attribute on drFrame, and have 
drFrame.SetStatusText() apply that format to all text before feeding it 
to wx.Frame.SetStatusText().  Plugin() would then change this 
StatusTextFormat.  You could implement this as either a function to be 
called, or use % string formatting...

Jeff Shannon
Technician/Programmer
Credit International




More information about the Python-list mailing list