option add

option add pattern value ?priority?

Adds a single entry to the option database. The entry will map any request that matches pattern to the value value (which will then be parsed by the widget; you need to use a syntactically correct value if you are making a value that a widget will read by default when it starts) with priority priority, which defaults to interactive.

Patterns consist of a sequence of words separated by dots, ".". Any sub-sequence of words and dots can be replaced by a wildcard, "*", except for the final word. It is advised to always make sure that you have a minimum of the final two words; it is very difficult to write good patterns that do not do this. Each word is a letter followed by any letter or digit; if the word begins with a capital letter, it is matched against the class of a widget or option, and if it begins with a lower-case letter, it is matched against the name of a widget. The overall pattern is matched against the full path of the widget with the name of the configuration property added, except that each element may be either the name or the class. The first component of the name matches against the class or name of the application (as set by options to wish); you probably always want a leading wildcard, with no elements at a higher level than the (class) name of the toplevel containing the widget.

Example

toplevel .t -class MyDialog

# Let this dialog's labels have large fonts by default!
option add *MyDialog*Label.font {Helvetica 48}

pack [label .t.lbl1 -text "First label"]
pack [label .t.lbl2 -text "Second label"]
pack [label .t.lbl3 -text "Third label"]