[wxPython] Special entry boxes for date, time, etc.

I'm wondering if anyone has an example of how to create
entry controls for dates, times, ip addresses, etc. I was
half hoping there was an 'entry mask' that could be specified.
It would be cool if we could build one in python, provided that
none actually exist.

I'm also interested in any reasonable ways to fake it. :slight_smile:

聽聽dd-mmm-yyyyy
聽聽hh:mm:sec:xxx
聽聽xxx.xxx.xxx.xxx

I'm wondering if anyone has an example of how to create
entry controls for dates, times, ip addresses, etc. I was
half hoping there was an 'entry mask' that could be specified.
It would be cool if we could build one in python, provided that
none actually exist.

I've had it on my list for quite some time to do entry formatting and
validation via a mask like this, but havn't gotten around to it yet. If
somebody would like to do it then it would be a welcome addition to the
library.

路路路

--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!

Tim Ottinger wrote:

I'm wondering if anyone has an example of how to create
entry controls for dates, times, ip addresses, etc. I was
half hoping there was an 'entry mask' that could be specified.
It would be cool if we could build one in python, provided that
none actually exist.

I'm also interested in any reasonable ways to fake it. :slight_smile:

  dd-mmm-yyyyy
  hh:mm:sec:xxx
  xxx.xxx.xxx.xxx

I don't bring a solution, but something to consider in this context:

An idiom for field validation that I really liked was (is?) used
in the PMW demos. (See http://pmw.sourceforge.net/)

The background colour of incorrectly entered fields was changed (to
pink in this case IIRC). This happened directly on entry, so with
a reqiurement that you needed to have an even number of characters
in the field, it was "blinking" as you typed.

You can obviously discuss whether the indication should appear
as you type or as you leave the field. That probably depends on
the situation, but I found this way of indicating errors very
good. It should probably be combined with a descriptive message
in the status line or as a tool tip.

This is very direct and it's not in your way.

I've seen horrible examples where you have to enter a date interval,
and if the last date was earlier than the first, you'll get a modal
dialog with an error message. You have to change the second (correct)
date to be able to leave that field. You get it...

Sorry that I'm going a bit off topic, but what I wanted to say is:
Perhaps entry-masks are fine, but they are not enough. Either because
the data in the field can't be described like that, or because the
relation between several fields matter.

In general, I find that one should restrict the freedom of the
user as little as possible, but indicate problems ASAP. More or
less like in spell-checking-as-you-type in word processors.

I'm even a bit hesitant to use entry-masks... As long as possible
I think it's better to inform the user of mistakes so that they can
correct then, than to force them to do things in a certain way.
Sometimes it might be good to "correct" entered data automagically.

Returning to word processors, I really hate when Word changes
http://something.com to a blue underlined link, or when it capitalizes
the word after a period, but in a data entry form, I would appreciate
that the program would let me enter a date like 010607 and change it
to 2001-06-07 on field exit.

That allows me to type as quickly as possible, and by changing the
formatting on field exit, I get a verification that the program has
interpreted the data as intended.

/Magnus

路路路

--
Magnus Lyck氓 | 脛lvans v盲g 99 | magnus@thinkware.se | tel: 070-582 80 65
Thinkware AB | 907 50 UME脜 | www.thinkware.se | fax: 070-612 80 65

Thanks all for the pointers to pmw and calendar control.

Regarding idioms, I think that there are a few interesting
things to consider generally. One is, as you said, confirming
that "the computer" understood what was typed. The other
is making sure that program's user knows what is expected.

So a mask is useful in the latter case, and reformatting after
entry in the former. I guess I could have used the wxGrid
with renderers and editors?

The idea of color for good/bad field values has always
appealed to me.

I agree with the idea that there are field domain
errors (wrong value for the type of data entered)
and also interfield errors (one field's value not
legal due to other fields' values). I certainly would
not like to make people have to go back and start
over, or enter bad-but-legal data in order to get
back to a field that is really wrong.

I can't remember the name or url of the paper,
but there is a pattern language on the web for
UI design that covers just these kinds of issues.
I've not looked at it in probably a year. I don't
remember much about it, because my first 20+
years of programming were gui-less. I've just
learned MFC (boo!) last year and wxPython and
TKinter are this year's 'thing'. So now that
I have some idea how bad GUI programming is
(MFC) and how good it can be (wxPython) maybe I
should go read that paper again.

But in the mean time I'll see if I can't find
a way to create some kind of composite control
for what I want. I'm really new to all of
this (wxPython for about 1-2 months, mostly
as a hobby), but I'll give it the old college try.

Tim

----- Original Message, excerpted -----

I don't bring a solution, but something to consider in this context:
[...]
The background colour of incorrectly entered fields was changed (to
pink in this case IIRC). This happened directly on entry, so with
a reqiurement that you needed to have an even number of characters
in the field, it was "blinking" as you typed.
[...]
Perhaps entry-masks are fine, but they are not enough. Either because
the data in the field can't be described like that, or because the
relation between several fields matter.

In general, I find that one should restrict the freedom of the
user as little as possible, but indicate problems ASAP. More or
less like in spell-checking-as-you-type in word processors.

[...] in a data entry form, I would appreciate
that the program would let me enter a date like 010607 and change it
to 2001-06-07 on field exit.

That allows me to type as quickly as possible, and by changing the
formatting on field exit, I get a verification that the program has
interpreted the data as intended.

路路路

From: "Magnus Lycka" <magnus@thinkware.se>
Subject: Re: [wxPython] Special entry boxes for date, time, etc.