12.07.2015 Views

Tkinter reference: A GUI for Python

Tkinter reference: A GUI for Python

Tkinter reference: A GUI for Python

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

sets all background options in the xparrot application to lime green. (Use the -nameoption on the command line when launching your application to set the name to xparrot.)The option-pattern part has this syntax:{{*|.} name}: : :optionThat is, each option-pattern is a list of zero or more names, each of which is preceded by anasterisk 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 name of a widget class (capitalized), or the name of an instance (lowercased).The way the option patterns work is a little complicated.example:*font: times 24Let’s start with a simpleThis line says that all font options should default to 24-point Times. The * is calledthe loose binding symbol, and means that this option pattern applies to any font optionanywhere in any application. Compare this example:*Listbox.font: lucidatypewriter 14The period between Listbox and font is called the tight binding symbol, and it meansthat this rule applies only to font options <strong>for</strong> widgets in class Listbox.As another example, suppose your xparrot application has instances of widgets of classJukebox. In order to set up a default background color <strong>for</strong> all widgets of that classJukebox, you could put a line in your options file like this:xparrot*Jukebox*background:PapayaWhipThe loose-binding (*) symbol between Jukebox and background makes this rule applyto any background attribute of any widget anywhere inside a Jukebox. Compare thisoption line:xparrot*Jukebox.background:NavajoWhiteThis rule will apply to the frame constituting the Jukebox widget itself, but because ofthe tight-binding symbol it will not apply to widgets that are inside the Jukebox widget.In the next section we’ll talk about how <strong>Tkinter</strong> figures out exactly which option value touse if there are multiple resource specification lines that apply.New Mexico Tech Computer Center <strong>Tkinter</strong> <strong>reference</strong>: Standardizing appearance Page 71

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!