1tk(n)                        Tk Built-In Commands                        tk(n)


8       tk - Manipulate Tk internal state


11       tk option ?arg arg ...?


15       The tk command provides access to miscellaneous elements of Tk's inter‐
16       nal state.  Most of the information manipulated by  this  command  per‐
17       tains  to the application as a whole, or to a screen or display, rather
18       than to a particular window.  The command can take any of a  number  of
19       different forms depending on the option argument.  The legal forms are:
21       tk appname ?newName?
22              If  newName  is  not specified, this command returns the name of
23              the application (the name that may be used in send  commands  to
24              communicate  with  the  application).   If newName is specified,
25              then the name of the application is changed to newName.  If  the
26              given name is already in use, then a suffix of the form “ #2” or
27#3” is appended in order to make the name  unique.   The  com‐
28              mand's  result  is the name actually chosen.  newName should not
29              start with a capital letter.  This will  interfere  with  option
30              processing, since names starting with capitals are assumed to be
31              classes;  as a result, Tk may not be able to find  some  options
32              for  the  application.   If sends have been disabled by deleting
33              the send command, this command will reenable them  and  recreate
34              the send command.
36       tk busy subcommand ...
37              This  command  controls  the  marking  of  window hierarchies as
38              “busy”, rendering them non-interactive while some  other  opera‐
39              tion is proceeding. For more details see the busy manual page.
41       tk caret window ?-x x? ?-y y? ?-height height?
42              Sets and queries the caret location for the display of the spec‐
43              ified Tk window window.  The caret  is  the  per-display  cursor
44              location  used  for indicating global focus (e.g. to comply with
45              Microsoft Accessibility guidelines), as well as for location  of
46              the  over-the-spot XIM (X Input Methods) or Windows IME windows.
47              If no options are specified, the last values  used  for  setting
48              the  caret  are  return  in option-value pair format.  -x and -y
49              represent window-relative coordinates, and -height is the height
50              of  the  current cursor location, or the height of the specified
51              window if none is given.
53       tk inactive ?-displayof window? ?reset?
54              Returns a positive integer, the number of milliseconds since the
55              last time the user interacted with the system. If the -displayof
56              option is given then the return value refers to the  display  of
57              window;  otherwise it refers to the display of the application's
58              main window.
60              tk inactive will return -1, if querying the user  inactive  time
61              is not supported by the system, and in safe interpreters.
63              If  the literal string reset is given as an additional argument,
64              the timer is reset and an empty string  is  returned.  Resetting
65              the  inactivity  time is forbidden in safe interpreters and will
66              throw an error if tried.
68       tk fontchooser subcommand ...
69              Controls the Tk font selection dialog. For more details see  the
70              fontchooser manual page.
72       tk scaling ?-displayof window? ?number?
73              Sets  and  queries the current scaling factor used by Tk to con‐
74              vert between physical units (for  example,  points,  inches,  or
75              millimeters)  and  pixels.   The  number  argument is a floating
76              point number that specifies the number of pixels  per  point  on
77              window's  display.   If  the  window  argument  is  omitted,  it
78              defaults to the main window.  If the number argument is omitted,
79              the current value of the scaling factor is returned.
81              A  “point” is a unit of measurement equal to 1/72 inch.  A scal‐
82              ing factor of 1.0 corresponds to 1 pixel  per  point,  which  is
83              equivalent  to  a  standard 72 dpi monitor.  A scaling factor of
84              1.25 would mean 1.25 pixels per point, which is the setting  for
85              a 90 dpi monitor; setting the scaling factor to 1.25 on a 72 dpi
86              monitor would cause everything in the  application  to  be  dis‐
87              played 1.25 times as large as normal.  The initial value for the
88              scaling factor is set when  the  application  starts,  based  on
89              properties  of  the  installed monitor, but it can be changed at
90              any time.  Measurements made after the scaling factor is changed
91              will  use  the  new  scaling factor, but it is undefined whether
92              existing widgets will resize themselves dynamically to  accommo‐
93              date the new scaling factor.
95       tk useinputmethods ?-displayof window? ?boolean?
96              Sets and queries the state of whether Tk should use XIM (X Input
97              Methods) for filtering events.  The resulting state is returned.
98              XIM  is used in some locales (i.e., Japanese, Korean), to handle
99              special input devices. This feature is only  significant  on  X.
100              If  XIM support is not available, this will always return 0.  If
101              the window argument is omitted, it defaults to the main  window.
102              If  the  boolean  argument  is  omitted,  the  current  state is
103              returned.  This is turned on by default for the main display.
105       tk windowingsystem
106              Returns the current Tk windowing system, one of x11 (X11-based),
107              win32 (MS Windows), or aqua (Mac OS X Aqua).


110       busy(n), fontchooser(n), send(n), winfo(n)


113       application name, send
117Tk                                    8.4                                tk(n)