The properties of a window are its dominant feature; properties constitute the window type.
There are roughly three groups of properties.
Various Properties
Visual properties, providing navigation aids, and visually establishing the window kind. Examples are: background, foreground, borderWidth, relief, highlightThickness...
This group defines the window colour scheme and shape. The used geometry manager may also change the window’s size.
Functional properties, these properties facilitate the connection to the application logic. Either by communicating certain states or by accepting input.
Events are related to these properties, events are later discussed in greater detail.
Examples for functional properties are: Call back properties like »command«; informational properties: listVariable, textVariable and variable...
These properties are visual aspects of the application logic.
Contents related properties communicate guidance through the Graphical User Interface. Examples are: image, text, label, state. Indicators also belong to this group, like indicatorOn and tear off.
There are two ways to set properties in Tk. The first method is to specify the property on the command line.
Example 7.2. Command Line Property
button .b \ -text "caption" \ -relief raised \ -command do-something
Properties, specified on the command line, are immutable, they cannot be altered through customization. Imutable is a disired restriction for functional and also for some contents related properties.
It should however not being used for properties, which communicate purpose through visual means: Like shape, dimensions, text, icon or colour, such properties better remain customizable.
The ability to customize window properties is implemented through the Option Database in Tcl/Tk.
Example 7.3. Option Database Properties
option add *Button.relief raised option add *b.text "caption" button .b -command do-something
Example 7.3, “Option Database Properties”, uses two Option Database entries to define the same properties as seen in Example 7.2, “Command Line Property”. The »relief« property is uniformly defined for all Button windows, whereas the »text« property is predefined for a single button. The button instance ».b« is present with its pathname and a leading asterisk (*) instead of a leading dot (.). The function »do-something« remains a command line property, because »do-something« is part of the application logic and must be imutable.
Combinations of Class and Instance names can used inside the Option Database. The latest Option Database is dominant to previous definitions.
Example 7.4. Dominant Properties
option add *b.relief sunken option add *Button.relief raised ;# Dominant, later to *b.relief # .b will feature a »raised« relief: button .b
Figure 7.1, “Preferences: Option DB”, shows the Jeszra Option Database »Generate« preferences page. There are a series of predefined properties, dedicated to certain usage scenarios. These different sets are themselves customizable and new sets can be defined as-well. On default: all properties from all sets are being used. Jeszra makes the maximum use of the Option Database.
Example 7.5. Details of Property background
-background background Background \
#d9d9d9 darkseagreen4
There are five atoms defining a property. The first atom is the command line argument. The second atom is the Option Database name, the third atom is the class name (for this property), the fourth atom is the default value and the last atom the real value. Example 7.5, “Details of Property background” displays all atoms for a background property. This list is only available through the»configure« command; which queries all window properties.
Jeszra evaluates the details of a property, it omits code generation when the real value is identical to the default value.