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
17
19 The option command allows you to add entries to the Tk option database
20 or to retrieve options from the database. The add form of the command
21 adds a new option to the database. Pattern contains the option being
22 specified, and consists of names and/or classes separated by asterisks
23 or dots, in the usual X format. Value contains a text string to asso‐
24 ciate with pattern; this is the value that will be returned in calls
25 to Tk_GetOption or by invocations of the option get command. If prior‐
26 ity is specified, it indicates the priority level for this option (see
27 below for legal values); it defaults to interactive. This command
28 always returns an empty string.
29
30 The option clear command clears the option database. Default options
31 (from the RESOURCE_MANAGER property or the .Xdefaults file) will be
32 reloaded automatically the next time an option is added to the database
33 or removed from it. This command always returns an empty string.
34
35 The option get command returns the value of the option specified for
36 window under name and class. If several entries in the option database
37 match window, name, and class, then the command returns whichever was
38 created with highest priority level. If there are several matching
39 entries at the same priority level, then it returns whichever entry was
40 most recently entered into the option database. If there are no match‐
41 ing entries, then the empty string is returned.
42
43 The readfile form of the command reads fileName, which should have the
44 standard format for an X resource database such as .Xdefaults, and adds
45 all the options specified in that file to the option database. If pri‐
46 ority is specified, it indicates the priority level at which to enter
47 the options; priority defaults to interactive.
48
49 The priority arguments to the option command are normally specified
50 symbolically using one of the following values:
51
52 widgetDefault
53 Level 20. Used for default values hard-coded into widgets.
54
55 startupFile
56 Level 40. Used for options specified in application-specific
57 startup files.
58
59 userDefault
60 Level 60. Used for options specified in user-specific defaults
61 files, such as .Xdefaults, resource databases loaded into the X
62 server, or user-specific startup files.
63
64 interactive
65 Level 80. Used for options specified interactively after the
66 application starts running. If priority is not specified, it
67 defaults to this level.
68
69 Any of the above keywords may be abbreviated. In addition, priorities
70 may be specified numerically using integers between 0 and 100, inclu‐
71 sive. The numeric form is probably a bad idea except for new priority
72 levels other than the ones given above.
73
75 Instruct every button in the application to have red text on it unless
76 explicitly overridden:
77 option add *button.foreground red startupFile
78
79 Allow users to control what happens in an entry widget when the Return
80 key is pressed by specifying a script in the option database and add a
81 default option for that which rings the bell:
82 entry .e
83 bind .e <Return> [option get .e returnCommand Command]
84 option add *.e.returnCommand bell widgetDefault
85
86
88 database, option, priority, retrieve
89
90
91
92Tk option(n)