[wxPython-users] Activating a clas from __init__ (without using wx.EVT_KEY_DOWN)

Josiah Carlson jcarlson at uci.edu
Tue Jul 18 22:57:41 PDT 2006


Walter Igo <walterigo at yahoo.com> wrote:
> I want to actavte the OnAutoFill Class so it will look at the
> StyledTextCtrl to autocomplete the word (not implemented yet) I have
> tried wx.EVT_Key_down, but this has led to problems. I just want it to
> repeat the OnAutoFill  activated message.

You could use the stc.EVT_STC_CHARADDED event...

> class MySTC(stc.StyledTextCtrl):
>     def __init__(self, parent, size=wx.DefaultSize, style=0):
>         stc.StyledTextCtrl.__init__(self, parent, size=size, style=style)
          self.Bind(stc.EVT_STC_CHARADDED, self.OnAutoFill)
>         
>     def OnAutoFill(self,event):
>         print "OnAutoFill Activated"
          p = self.GetCurrentPos()
          st = self.WordStartPosition(p, 1)
          en = self.WordEndPosition(p, 1)
          #The current "word" is self.GetTextRange(st,en)

[snip]

 - Josiah





More information about the wxpython-users mailing list