[wxPython-users] Wx.EVT_TEXT Help.

Saketh Bhamidipati saketh.bhamidipati at gmail.com
Thu Jul 6 13:24:43 PDT 2006


On 7/6/06, Walter Igo <walterigo at yahoo.com> wrote:
>
> I have a small program and I only want it to write the letter that I press
> to the text window. but I cant keep it form looping. simple problem. and
> probley more of a python problem. but how can i get the program to show j=
ust
> one charater on the screen at a time and then exit the loop.
>
>
> Walter Igo
> walterigo at yahoo.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users-help at lists.wxwidgets.org
>
>
> First of all, I think you should use self.Bind instead of panel.Bind.

Your problem is that in your CharLoop method, the WriteText triggers a
EVT_TEXT, which in turn triggers the method again, causing an infinite loop.
This is a problem - infinite loops are bad! You also want to get the text
from the event, not from the control itself. Use

I think what you want is to just leave it as a regular TextCtrl. Try
removing the parts of your code that deal with an EVT_TEXT, for right now.

I don't exactly understand what it is you want as the end result, but a
regular TextCtrl without the EVT_TEXT event bound should solve your problem.
If you only want it to show one character at a time, then you're better off
not using a multiline TextCtrl. However, if you are trying to get this to
work as a small example, then I would suggest that you move on to dealing
with multiple characters instead of restricting yourself to a single one.
Other widgets are better for getting single characters as input.

-Saketh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/200607=
06/0a39f9e3/attachment.htm


More information about the wxpython-users mailing list