Next / Previous / Contents / Shipman's homepage

2. Controls in the FontSelect widget

Here is a screen shot of the widget as it appears in Section 4, “fontselector: A small test driver”.

These are the components of a FontSelect widget:

family picker

A scrollable Listbox widget containing the names of all the font families such as Times, Courier, and so forth. The label above this widget advises the user to click to select a font family.

annunciator

A Label field that displays the full name of the currently selected font, e.g., “times 16 bold italic”. Because not all fonts are available in all sizes, this field will reflect the actual font closest to the selected values, not the selected values themselves.

sample text

A Label field that displays a few characters in the selected font. The user can add or edit text in this field. The initial contents are: zero, letter O, digit 1, lowercase letter l, capital letter I, and the vertical bar symbol “|”. Beware of fonts that make it difficult or impossible to tell all these characters apart!

size field and button

A text Entry field for the font size in pixels, and an accompanying Button labeled “Set” that applies the font size value. The user can also apply the font size by pressing Enter or Tab in that field.

bold button

A push-push Checkbutton to specify whether the font is boldfaced or not.

italic button

A push-push Checkbutton to specify whether the font is italic or not.

2.1. Design notes

In the author's opinion, the most obvious design tradeoff is in the size of the listbox of family names. At this writing, there were over sixty names.

  • Making the listbox larger makes life easier for the user, who can see more names at once, and needs to do less scrolling to see all the names.

  • On the other hand, this widget may be included in a larger application where space is at a premium.

The design shown above can be adapted to smaller or larger screen sizes by changing the size of the listbox. Accordingly, in the widget constructor, we will allow the user to specify that size (overriding some reasonable default).