1itclvars(n) [incr Tcl] itclvars(n)
2
3
4
5______________________________________________________________________________
6
8 itclvars - variables used by [incr Tcl]
9______________________________________________________________________________
10
11
13 The following global variables are created and managed automatically by
14 the [incr Tcl] library. Except where noted below, these variables
15 should normally be treated as read-only by application-specific code
16 and by users.
17
18 itcl::library
19 When an interpreter is created, [incr Tcl] initializes this
20 variable to hold the name of a directory containing the system
21 library of [incr Tcl] scripts. The initial value of
22 itcl::library is set from the ITCL_LIBRARY environment variable
23 if it exists, or from a compiled-in value otherwise.
24
25 itcl::patchLevel
26 When an interpreter is created, [incr Tcl] initializes this
27 variable to hold the current patch level for [incr Tcl]. For
28 example, the value "2.0p1" indicates [incr Tcl] version 2.0 with
29 the first set of patches applied.
30
31 itcl::purist
32 When an interpreter is created containing Tcl/Tk and the
33 [incr Tcl] namespace facility, this variable controls a "back‐
34 ward-compatibility" mode for widget access.
35
36 In vanilla Tcl/Tk, there is a single pool of commands, so the
37 access command for a widget is the same as the window name.
38 When a widget is created within a namespace, however, its access
39 command is installed in that namespace, and should be accessed
40 outside of the namespace using a qualified name. For example,
41
42 namespace foo {
43 namespace bar {
44 button .b -text "Testing"
45 }
46 }
47 foo::bar::.b configure -background red
48 pack .b
49
50 Note that the window name ".b" is still used in conjunction with
51 commands like pack and destroy. However, the access command for
52 the widget (i.e., name that appears as the first argument on a
53 command line) must be more specific.
54
55 The "winfo command" command can be used to query the fully-qual‐
56 ified access command for any widget, so one can write:
57
58 [winfo command .b] configure -background red
59
60 and this is good practice when writing library procedures.
61 Also, in conjunction with the bind command, the "%q" field can
62 be used in place of "%W" as the access command:
63
64 bind Button <Key-Return> {%q flash; %q invoke}
65
66 While this behavior makes sense from the standpoint of encapsu‐
67 lation, it causes problems with existing Tcl/Tk applications.
68 Many existing applications are written with bindings that use
69 "%W". Many library procedures assume that the window name is
70 the access command.
71
72 The itcl::purist variable controls a backward-compatibility
73 mode. By default, this variable is "0", and the window name can
74 be used as an access command in any context. Whenever the
75 unknown procedure stumbles across a widget name, it simply uses
76 "winfo command" to determine the appropriate command name. If
77 this variable is set to "1", this backward-compatibility mode is
78 disabled. This gives better encapsulation, but using the window
79 name as the access command may lead to "invalid command" errors.
80
81 itcl::version
82 When an interpreter is created, [incr Tcl] initializes this
83 variable to hold the version number of the form x.y. Changes to
84 x represent major changes with probable incompatibilities and
85 changes to y represent small enhancements and bug fixes that
86 retain backward compatibility.
87
88
90 itcl, variables
91
92
93
94itcl 3.0 itclvars(n)