Chapter 16. User Customization

When writing Perl/Tk applications, we can change the look of the application dramatically by using different options when creating widgets. We can give our users a similar type of control using the resource database or command-line options. The user has the ability to change the appearance of almost anything, from the width of widget edges and the fonts used to display text to the cursor shown as the mouse passes over a widget. A change can be global to every application that honors the option database or so specific that it changes a single option of a single widget.

In the first part of this chapter, we’ll cover the ways users can change these visual aspects from the command line. Later in the chapter, we’ll give you more ideas on how to utilize a resource database.

The term resource database originated in the X Window System. Essentially, the resource database provides user-specified values for widget configuration options. When creating a new widget, Tk queries the resource database for all options that the programmer did not explicitly specify on the widget creation command. If an option/value pair (sometimes called a resource) isn’t found in the resource database, Tk uses the option’s default value provided by the widget’s class.

Actually, a resource is a bit more complicated. Although the resource identifies a single option/value pair, it may apply to more than a single widget. Using class names and the wildcard character (*), it’s ...

Get Mastering Perl/Tk 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.