bend or redirect a class method and then call it again
Franz Steinhaeusler
franz.steinhaeusler at utanet.at
Thu Jul 22 02:46:53 EDT 2004
On Wed, 21 Jul 2004 12:21:33 -0700, Scott David Daniels
<Scott.Daniels at Acm.Org> wrote:
>[...]
>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)
>
thank you,
I was not exact enough.
It was not so easy, because I had to apply the super in a function
and not in the class itself.
but finally i got it to work:
#drFrame is inherited from wx.Frame
#in drFrame there are some calls to SetStatusText
import wx
from drpython import DrFrame
def Plugin(DrFrame):
def SetStatusText(text, col):
if col == 1:
#text.find
ind1 = text.find ("Col: ")
if ind1 > -1:
ind1 += len ("Col: ");
ind2 = text.find (" ", ind1)
nr = int (text [ind1:ind2]) + 1
text = text [:ind1] + str (nr) + text[ind2:]
super(type(DrFrame), DrFrame).SetStatusText(text, col)
def NewStatusText(text, col=0):
SetStatusText(text, col)
setattr(DrFrame, 'SetStatusText', NewStatusText)
Is there a better/simpler/clearer solution?
thank you
--
Franz Steinhaeusler
More information about the Python-list
mailing list