On Tue, Jun 10, 2003 at 04:46:12PM -0500, Art Haas wrote:
> On Tue, Jun 10, 2003 at 02:34:17PM -0700, Shannon -jj Behrens wrote:
> > I had to do something similar.  I recommend the following (pseudocode):
> > 
> > def on_init:
> >     old_text = "whatever"
> > 
> > def on_changed:
> >     if not is_valid(new_text):
> >             new_text = old_text
> >     else:
> >             old_text = new_text
> > 
> > In this way, he can never enter anything into the box that's invalid,
> > and his cursor will always be at the end of the entry box waiting to
> > type more valid stuff.  
> > 
> 
> I'm guessing you bind the on_changed() method to the "changed" signal,
> but I think at that point the new character has already been added into
> the entry box, so are you replacing the text in the entry box every
> time?

That is correct.  I can see that you might be afraid of performance
problems, but it worked for me without any noticeable lags.

-jj

-- 
Hacker is to software engineer as 
Climbing Mt. Everest is to building a Denny's there.
_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to