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 file is read through a channel which is in "utf-8" encoding,
49 invalid byte sequences are automatically converted to valid ones. This
50 means that encodings like ISO 8859-1 or cp1252 with high probability
51 will work as well, but this cannot be guaranteed. This cannot be
52 changed, setting the [encoding system] has no effect.
53
54 The priority arguments to the option command are normally specified
55 symbolically using one of the following values:
56
57 widgetDefault
58 Level 20. Used for default values hard-coded into widgets.
59
60 startupFile
61 Level 40. Used for options specified in application-specific
62 startup files.
63
64 userDefault
65 Level 60. Used for options specified in user-specific defaults
66 files, such as .Xdefaults, resource databases loaded into the X
67 server, or user-specific startup files.
68
69 interactive
70 Level 80. Used for options specified interactively after the
71 application starts running. If priority is not specified, it
72 defaults to this level.
73
74 Any of the above keywords may be abbreviated. In addition, priorities
75 may be specified numerically using integers between 0 and 100, inclu‐
76 sive. The numeric form is probably a bad idea except for new priority
77 levels other than the ones given above.
78
80 Patterns consist of a sequence of words separated by either periods,
81 “.”, or asterisks “*”. The overall pattern may also be optionally pre‐
82 ceded by an asterisk.
83
84 Each word in the pattern conventionally starts with either an upper-
85 case letter (in which case it denotes the class of either a widget or
86 an option) or any other character, when it denotes the name of a widget
87 or option. The last word in the pattern always indicates the option;
88 the preceding ones constrain which widgets that option will be looked
89 for in.
90
91 When two words are separated by a period, the latter widget must be a
92 direct child of the former (or the option must apply to only the indi‐
93 cated widgets). When two words are separated by an asterisk, any depth
94 of widgets may lie between the former and latter widgets (and the
95 option applies to all widgets that are children of the former widget).
96
97 If the overall pattern is preceded by an asterisk, then the overall
98 pattern applies anywhere it can throughout the whole widget hierarchy.
99 Otherwise the first word of the pattern is matched against the name and
100 class of the “.” toplevel, which are usually set by options to wish.
101
103 Instruct every button in the application to have red text on it unless
104 explicitly overridden, by setting the foreground for the Button class
105 (note that on some platforms the option is ignored):
106 option add *Button.foreground red startupFile
107
108 Allow users to control what happens in an entry widget when the Return
109 key is pressed by specifying a script in the option database and add a
110 default option for that which rings the bell:
111 entry .e
112 bind .e <Return> [option get .e returnCommand Command]
113 option add *.e.returnCommand bell widgetDefault
114
116 options(n), wish(1)
117
119 database, option, priority, retrieve
120
121
122
123Tk option(n)