StyledTextCtrl questions

Quick first aid.

Basic recipe. You should test the pressed keys and not the
text of the STC by using a correct event handler.

Replace
         self.Bind(stc.EVT_STC_MODIFIED, self.TextEntered)
with
      #test pressed keys
         self.Bind(wx.EVT_KEY_DOWN, self.TextEntered)

and then use the following modified method

     def TextEntered(self, evt):
         if evt.GetKeyCode() == wx.WXK_RETURN:
             #for debugging
             print "you hit enter!!!"
             #add the text
             self.AddText("maakla maakla maakla maakla")
             #add a <nl>, don't forget import os
             self.AddText(os.linesep)
             #now, we are in the "next line", ready for a prompt
             self.MarkerAdd(self.GetCurrentLine(), 0)
             #do not skip event here
         else:
             #processing other keys normally
             evt.Skip()

Events handling in STC is a science by itself.
See http://www.yellowbrain.com/stc/events.html, a little bit outdated, but
still a valuable source of informations.

You already know PyShell, dive in it.

Jean-Michel Fauth, Switzerland

Thanks.

I've tried to follow the PyShell code to understand how they handle
autocompletion but I'm getting nowhere. Any ideas on how to do it?

Regards,
Simon.

Look in wx.py.shell, in particular the OnChar, OnKeyDown, autoCompleteShow,
and autoCallTipShow methods of the 'Shell' class.

- Josiah

···

simon kagwe <simonkagwe@yahoo.com> wrote:

I've tried to follow the PyShell code to understand how they handle
autocompletion but I'm getting nowhere. Any ideas on how to do it?