-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Python GUI Programming with Tkinter, 2nd edition
By :

With our specification in hand and our requirements clear, it's time to start designing our solution. The main focus of our application is the data entry form itself, so we'll begin with that GUI component.
We're going to create a basic design for our form in three steps:
Without committing ourselves to a particular GUI library or widget set, we can start our form design by deciding on an appropriate input widget type for each field. Most toolkits come with the same basic types of inputs for different types of data.
We've already seen some of these in our look at Tkinter, but let's see what sort of options are likely to be available:
Widget type |
Tkinter example |
Used for |
Line entry |
|
Single-line strings |
Number entry |
|
Integer or decimal values |
Select list (drop-down) |
|
Choice between many distinct values |
Check box |
|
True/false value |
Radio button |
|
Choice between a few distinct values |
Text entry |
|
Multi-line text entry |
Date entry |
(None specific) |
Dates |
Looking at our data dictionary, what sort of widgets should we pick out for each of our fields? Let's consider:
Spinbox
, for these.Spinbox
widget is the right choice.Our final analysis comes to the following:
Field |
Widget type |
Date |
Date entry |
Time |
Select list |
Lab |
Radio buttons |
Technician |
Text entry |
Plot |
Select list |
Seed Sample |
Text entry |
Fault |
Check box |
Humidity |
Number entry |
Light |
Number entry |
Temperature |
Number entry |
Blossoms |
Number entry |
Fruit |
Number entry |
Plants |
Number entry |
Max Height |
Number entry |
Median Height |
Number entry |
Min Height |
Number entry |
Notes |
Text entry |
Bear in mind, this analysis is not set in stone; it will almost certainly be revised as we receive feedback from our users, as the application's use case evolves, or as we become more familiar with the capabilities and limitations of Python and Tkinter. This is simply a starting place from which we can create an initial design.
Humans tend to get confused when staring at a huge wall of inputs in no particular order. You can do your users a big favor by breaking up the input form into sets of related fields. Of course, that assumes that your data has related sets of fields, doesn't it? Does our data have groups?
Recall some of the information we gathered during our interviews:
Details like this tell you a lot about how your users think about their data, and that should inform how the application presents that data.
Considering all this, you identify the following related groups:
Most GUI libraries offer a variety of ways to group sections of a form together; think of some you have seen. A few are listed in this table:
Widget type |
Description |
Tabs (notebook) |
Allows multiple tabbed pages that the user can switch between |
Frames/boxes |
Draws boxes around sections of a form, sometimes with a header |
Accordion |
Divides a form into sections that can be hidden or expanded one at a time |
Framed boxes are the simplest way to break up a GUI. In cases where there are a lot of fields, a tabbed or accordion widget can help by hiding fields the user isn't working with. However, they require additional user interaction to switch between pages or sections. You decide, after some consideration, that framed boxes with headers will be perfectly adequate for this form. There are not really enough fields to justify separate pages, and switching between them would just add more overhead to the data entry process.
So far, we know that we have 17 inputs, which are grouped as follows:
We want to group the preceding inputs using some kind of box or frame with a header label. Notice that two of the first three sections have widgets in multiples of three. That suggests that we could arrange them in a grid with three items across. How should we order the fields within each group?
Ordering of fields seems like a trivial item, but for the user it can make a significant difference in usability. Users who have to jump around a form haphazardly to match their workflow are more likely to make mistakes.
As you learned, the data is entered from paper forms filled out by the lab technicians. Refer back to the screenshot of the paper form shown in Figure 2.1 in the previous section. It looks like items are mostly grouped the way our records are grouped, so we'll use the ordering on this form to order our fields. That way, data entry clerks can zip right through the form from top to bottom, left to right, without having to bounce around the screen.
Remember, user workflow is important! When designing a new application to replace some part of an existing procedure, it's crucial to respect the established workflow. While improving the status quo may require adjusting the workflow, be careful that you aren't making someone else's job harder without a good reason.
One last consideration in our design is where to place field labels in relation to the fields. There is a good deal of debate in the UI design community over the best placement of labels, but the consensus is that one of the following two options is best:
You might try sketching out both to see which you prefer, but for this application, labels above fields will probably work better for the following reasons:
The one exception is the check button field; check buttons are typically labeled to the right of the widget.
Take a moment to make a mockup of your form, using paper and pencil, or a drawing program if you prefer. Your form should look something like this:
Figure 2.3: The form layout
With your form designed, it's time to consider the rest of the application's GUI:
Adding the following things to our sketch, we have something like the following screenshot:
Figure 2.4: The application layout
Looks good! Your final step is to show these designs to your users and the director for any feedback or approval. Good luck!
Keep stakeholders – your boss, users, and others who will be affected by your program – involved as much as possible in your application design process. This reduces the possibility that you'll have to go back and redesign your application later.
Change the font size
Change margin width
Change background colour