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 namespace foo {
42 namespace bar {
43 button .b -text "Testing"
44 }
45 }
46 foo::bar::.b configure -background red
47 pack .b
48 Note that the window name ".b" is still used in conjunction with com‐
49 mands like pack and destroy. However, the access command for the wid‐
50 get (i.e., name that appears as the first argument on a command line)
51 must be more specific.
52
53 The "winfo command" command can be used to query the fully-qualified
54 access command for any widget, so one can write:
55 [winfo command .b] configure -background red
56 and this is good practice when writing library procedures. Also, in
57 conjunction with the bind command, the "%q" field can be used in place
58 of "%W" as the access command:
59 bind Button <Key-Return> {%q flash; %q invoke}
60 While this behavior makes sense from the standpoint of encapsulation,
61 it causes problems with existing Tcl/Tk applications. Many existing
62 applications are written with bindings that use "%W". Many library
63 procedures assume that the window name is the access command.
64
65 The itcl::purist variable controls a backward-compatibility mode. By
66 default, this variable is "0", and the window name can be used as an
67 access command in any context. Whenever the unknown procedure stumbles
68 across a widget name, it simply uses "winfo command" to determine the
69 appropriate command name. If this variable is set to "1", this back‐
70 ward-compatibility mode is disabled. This gives better encapsulation,
71 but using the window name as the access command may lead to "invalid
72 command" errors.
73
74 itcl::version
75 When an interpreter is created, [incr Tcl] initializes this
76 variable to hold the version number of the form x.y. Changes to
77 x represent major changes with probable incompatibilities and
78 changes to y represent small enhancements and bug fixes that
79 retain backward compatibility.
80
81
83 itcl, variables
84
85
86
87itcl 3.0 itclvars(n)