Strategies to prevent data errors

There is no universal answer to how a widget should react to a user trying to enter bad data. The validation logic found in various graphics toolkits can differ greatly; when bad data is entered, an input widget might validate the user input as follows:

  • Prevent the invalid keystrokes from registering at all
  • Accept the input, but return an error or list of errors when the form is submitted
  • Show an error when the user leaves the entry field, perhaps disabling form submission until it's corrected
  • Lock the user in the entry field until valid data is entered
  • Silently correct the bad data using a best-guess algorithm

The correct behavior in a data entry form (which is filled out hundreds of times a day by users ...

Get Python GUI Programming with Tkinter now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.