option add
Adds an entry to the option database.
option add PATTERN VALUE ?PRIORITY?
Description
Adds the entry of PATTERN with VALUE. The new widgets after the call get the value. PRIORITY is a number from 0 to 100, or one of the words of the table below. The default is interactive.
Arguments
| Argument | Type | Default | Description | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| PATTERN | pattern | required | The words of the widget tree and the option, each after a . or a *. | ||||||||||
| VALUE | string | required | The value of the option for each widget that matches. | ||||||||||
| PRIORITY | priority | interactive | The priority of the entry: a number from 0 to 100, or a word.
|
Returns
An empty string.
Examples
# The entry with the higher priority wins, also when it came first.
% option add *Label.text first 30
> option add *Label.text second 20
> label .l
> .l cget -text
first
# A widget that exists keeps its options.
% option clear
> label .early
> option add *Label.text late
> .early cget -text
Errors
% option add *x 1 101
bad priority level "101": must be widgetDefault, startupFile, userDefault, interactive, or a number between 0 and 100
-errorcode NONE
% option add *x 1 high
bad priority level "high": must be widgetDefault, startupFile, userDefault, interactive, or a number between 0 and 100
-errorcode NONE
% option add *x
wrong # args: should be "option add pattern value ?priority?"
-errorcode TCL WRONGARGS
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztk 1.0.0-beta.1