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
;
the second form sets options for all applications.app
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
part has this syntax:option-pattern
{{*|.}name
}...option
That is, each
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:option-pattern
the name of a widget class (capitalized), or
the name of an instance (lowercased).
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
attribute 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.