O'Reilly logo

Learning Perl/Tk by Nancy Walsh

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

5.2. The Entry Widget

Until now, the only input we know how to get from the user is a mouseclick on a button widget (Button, Checkbutton, or Radiobutton), which is handled via the -command option. Getting input from a mouseclick is useful, but it's also limiting. The entry widget will let the user type in text that can then be used in any way by the application. Here are a few examples of where you might use an entry widget:

  • In a database form that requires one entry per field (e.g., Name, Last name, Address)

  • In a software registration window that requires a serial number

  • In a login window that requires a username and password

  • In a configuration window to get the name of a printer

  • In an Open File window that requires the path and name of a file

Normally, we don't care what users type in an entry widget until they are done typing, and any processing will happen "after the fact" when a user clicks some sort of Go button. You could get fancy and process each character as it's typed by setting up a complicated bind—but it is probably more trouble than it is worth.

The user can type anything into an entry widget. It is up to the programmer to decide if the text entered is valid or not. When preparing to use the information from an entry, we should do some error checking. If we want an integer and get some alphabetic characters, we should issue a warning or error message to the user.

An ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required