1option(n) Tk Built-In Commands option(n)
2
3
4
5______________________________________________________________________________
6
8 option - Add/retrieve window options to/from the option database
9
11 option add pattern value ?priority?
12 option clear
13 option get window name class
14 option readfile fileName ?priority?
15_________________________________________________________________
16
18 The option command allows you to add entries to the Tk option database
19 or to retrieve options from the database. The add form of the command
20 adds a new option to the database. Pattern contains the option being
21 specified, and consists of names and/or classes separated by asterisks
22 or dots, in the usual X format (see PATTERN FORMAT). Value contains a
23 text string to associate with pattern; this is the value that will be
24 returned in calls to Tk_GetOption or by invocations of the option get
25 command. If priority is specified, it indicates the priority level for
26 this option (see below for legal values); it defaults to interactive.
27 This command always returns an empty string.
28
29 The option clear command clears the option database. Default options
30 (from the RESOURCE_MANAGER property or the .Xdefaults file) will be
31 reloaded automatically the next time an option is added to the database
32 or removed from it. This command always returns an empty string.
33
34 The option get command returns the value of the option specified for
35 window under name and class. If several entries in the option database
36 match window, name, and class, then the command returns whichever was
37 created with highest priority level. If there are several matching
38 entries at the same priority level, then it returns whichever entry was
39 most recently entered into the option database. If there are no match‐
40 ing entries, then the empty string is returned.
41
42 The readfile form of the command reads fileName, which should have the
43 standard format for an X resource database such as .Xdefaults, and adds
44 all the options specified in that file to the option database. If pri‐
45 ority is specified, it indicates the priority level at which to enter
46 the options; priority defaults to interactive.
47
48 The priority arguments to the option command are normally specified
49 symbolically using one of the following values:
50
51 widgetDefault
52 Level 20. Used for default values hard-coded into widgets.
53
54 startupFile
55 Level 40. Used for options specified in application-specific
56 startup files.
57
58 userDefault
59 Level 60. Used for options specified in user-specific defaults
60 files, such as .Xdefaults, resource databases loaded into the X
61 server, or user-specific startup files.
62
63 interactive
64 Level 80. Used for options specified interactively after the
65 application starts running. If priority is not specified, it
66 defaults to this level.
67
68 Any of the above keywords may be abbreviated. In addition, priorities
69 may be specified numerically using integers between 0 and 100, inclu‐
70 sive. The numeric form is probably a bad idea except for new priority
71 levels other than the ones given above.
72
74 Patterns consist of a sequence of words separated by either periods,
75 “.”, or asterisks “*”. The overall pattern may also be optionally pre‐
76 ceded by an asterisk.
77
78 Each word in the pattern conventionally starts with either an upper-
79 case letter (in which case it denotes the class of either a widget or
80 an option) or any other character, when it denotes the name of a widget
81 or option. The last word in the pattern always indicates the option;
82 the preceding ones constrain which widgets that option will be looked
83 for in.
84
85 When two words are separated by a period, the latter widget must be a
86 direct child of the former (or the option must apply to only the indi‐
87 cated widgets). When two words are separated by an asterisk, any depth
88 of widgets may lie between the former and latter widgets (and the
89 option applies to all widgets that are children of the former widget).
90
91 If the overall pattern is preceded by an asterisk, then the overall
92 pattern applies anywhere it can throughout the whole widget hierarchy.
93 Otherwise the first word of the pattern is matched against the name and
94 class of the “.” toplevel, which are usually set by options to wish.
95
97 Instruct every button in the application to have red text on it unless
98 explicitly overridden (note that on some platforms the option is
99 ignored):
100 option add *Button.foreground red startupFile
101
102 Allow users to control what happens in an entry widget when the Return
103 key is pressed by specifying a script in the option database and add a
104 default option for that which rings the bell:
105 entry .e
106 bind .e <Return> [option get .e returnCommand Command]
107 option add *.e.returnCommand bell widgetDefault
108
110 options(n), wish(1)
111
113 database, option, priority, retrieve
114
115
116
117Tk option(n)