Activating a clas from __init__ (without using wx.EVT_KEY_DOWN)

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.

thanks.

import wx
import wx.stc as stc
import re

class MySTC(stc.StyledTextCtrl):

def __init__(self, parent, size=wx.DefaultSize, style=0):
    stc.StyledTextCtrl.__init__(self, parent, size=size, style=style)
   
   
def OnAutoFill(self,event):
    print "OnAutoFill Activated"
    event.Skip()

class TestFrame(wx.Frame):

def init(self):
global MainEditor
wx.Frame.init(self, None, -1, ‘Walts Program’)
MainEditor = MySTC(self)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(MainEditor, 1, wx.EXPAND)
self.SetSizer(sizer)
self.SetSize((400, 400))

if name==“main”:
app = wx.PySimpleApp()
win = TestFrame()
win.Show(True)
app.MainLoop()

Walter Igo 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.

What problems?

I just want it to repeat the OnAutoFill activated message.

What do you mean by "repeat"? Do you want it to be called for every key stroke or in response to some other event? Do you want it to be called even if no keys are pressed?

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

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

···

Walter Igo <walterigo@yahoo.com> wrote:

Thanks that is the command I was looking for. This group is a great help to me. I am making progress every day. sometimes not as much as I like, but progress never the less.

···

----- Original Message ----
From: Josiah Carlson jcarlson@uci.edu
To: Walter Igo walterigo@yahoo.com; wxPython Suport list. wxpython-users@lists.wxwidgets.org
Sent: Tuesday, July 18, 2006 11:57:41 PM
Subject: Re: [wxPython-users] Activating a clas from init (without using wx.EVT_KEY_DOWN)

Walter Igo walterigo@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