[Tutor] PythonCard error checking

Michael Langford mlangford.cs03 at gtalumni.org
Mon Dec 24 17:57:46 CET 2007


While I'm a user, I'm not a guru. Those are at:
https://lists.sourceforge.net/lists/listinfo/pythoncard-users for
pythoncard.

I know a common technique is on a button event for the "ok" or "apply"
button is to validate all the text fields in an exception safe setting. On
exception exit the event handler make an error notice. You could even color
the guilty text box text red then exit the event handler. Only if all the
boxes make it through, do you actually process the input.

GUI code often is...hairy...when done correctly. That's why is should be
separated into its own files: to keep the hair out of your main program.

        --Michael

On Dec 24, 2007 10:02 AM, Roy Chen <roychenlei at gmail.com> wrote:

> Hello everyone,
>
> I've just started trying PythonCard to build a simple GUI for a little
> application I'm writing.
> Just wondering if anyone knows the "proper" way to do some simple error
> checking:
> for example, I have a textField, and I wish to check that only integers
> within a certain
> range are entered into it.
>
> I know I can just enclose that block of code in a try .. except clause,
> just that I'm not sure
> what to do once I've caught say, a ValueError exception. It certainly
> would not be a fatal
> error and I would like to prompt the user to re-enter the value, but how
> should I return to
> that point of program execution?
>
> Any help from the PythonCard gurus would be appreciated. Happy holidays!
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>


-- 
Michael Langford
Phone: 404-386-0495
Consulting: http://www.RowdyLabs.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20071224/778ca7e8/attachment.htm 


More information about the Tutor mailing list