Version 4 of Time entry that never contains invalid data

Updated 2005-11-10 15:25:10

KBK observes:

At one point, I had a customer who wanted an entry field that would validate a time of day (HH:MM:SS); actually, since the application was for video processing, the time also included a frame count within the second, but that's not really relevant to the discussion. The customer found "validate-on-focus-out" to be unacceptable: he wanted the field NEVER to have invalid content. What the customer (and, surprisingly, the users) actually liked was to put a sample time in the field, and set up the keyboard bindings to function in overtype mode. The key bindings got to be a bit complicated, since they were dependent on the location of the entry cursor.

Here's the code, in case anyone else finds the idea useful:


(ugh, I've found that it's too big for my browser to accept in the text area. I promise to find another place to put it.)

RS is happy again that he likes tiny code snippets which fit between thumb and index finger..;-)


Also see timeentry.


KPV I did something similar a while ago for both date and time. The datefield widget is part TkLib but a newer version with support for different date formats can be found at tcl-only datefield.

The timefield widget only supported "HH::MM" but was only about 100 lines long. If anyone is interested, I could post it here on this wiki.