Next / Previous / Contents

27.3. Resource specification lines

Each line in an option file specifies the value of one or more options in one or more applications and has one of these formats:

app option-pattern: value
option-pattern: value

The first form sets options only when the name of the application matches app; the second form sets options for all applications.

For example, if your application is called xparrot, a line of the form

xparrot*background: LimeGreen

sets all background options in the xparrot application to lime green. (Use the -name option on the command line when launching your application to set the name to 'xparrot'.)

The option-pattern part has this syntax:

{{*|.}name}...option

That is, each option-pattern is a list of zero or more names, each of which is preceded by an asterisk or period. The last name in the series is the name of the option you are setting. Each of the rest of the names can be either:

The way the option patterns work is a little complicated. Let's start with a simple example:

*font: times 24

This line says that all font options should default to 24-point Times. The * is called the loose binding symbol, and means that this option pattern applies to any font option anywhere in any application. Compare this example:

*Listbox.font: lucidatypewriter 14

The period between Listbox and font is called the tight binding symbol, and it means that this rule applies only to font options for widgets in class Listbox.

As another example, suppose your xparrot application has instances of widgets of class Jukebox. In order to set up a default background color for all widgets of that class Jukebox, you could put a line in your options file like this:

xparrot*Jukebox*background: PapayaWhip

The loose-binding (*) symbol between Jukebox and background makes this rule apply to any background option of any widget anywhere inside a Jukebox. Compare this option line:

xparrot*Jukebox.background: NavajoWhite

This rule will apply to the frame constituting the Jukebox widget itself, but because of the tight-binding symbol it will not apply to widgets that are inside the Jukebox widget.

In the next section we'll talk about how Tkinter figures out exactly which option value to use if there are multiple resource specification lines that apply.