[wxPython-users] Wx.EVT_TEXT Help.

Saketh Bhamidipati saketh.bhamidipati at gmail.com
Thu Jul 6 13:25:49 PDT 2006


On 7/6/06, Saketh Bhamidipati <saketh.bhamidipati at gmail.com> wrote:
>
>
>
> 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 probl=
em.
> > and probley more of a python problem. but how can i get the program to =
show
> > just 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 lo=
op.
> 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 probl=
em.
> If you only want it to show one character at a time, then you're better o=
ff
> 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
>
Oh, I'm mistaken about the getting the text part of it. You should use
self.TextWindow.GetValue() to get the text. I was mixing up CommandEvents
with other events in my head.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/200607=
06/3b5fbeda/attachment.htm


More information about the wxpython-users mailing list