here2share

Tcl/Tk Reference Guide --

May 13th, 2021
733
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 223.82 KB | None | 0 0
  1. Tcl/Tk Reference Guide
  2. for Tcl 8.4.3 / Tk 8.4.3
  3.  
  4. Tk/Tcl program designed and created by
  5. John Ousterhout
  6.  
  7. Reference guide contents written by
  8. Paul Raines <raines@slac.stanford.edu>
  9. Jeff Tranter <tranter@pobox.com>
  10. Dave Bodenstab <dave@bodenstab.org>
  11. Reference guide format designed and created by
  12. Johan Vromans <jvromans@squirrel.nl>
  13. Tcl/Tk Reference Guide
  14. Contents
  15. 1. Tcl Shell . . . . . . . . . . . . . . . . . . . . . . . . . 5
  16. 2. Basic Tcl Language Features . . . . . . . . . . . . . . . 5
  17. 3. Tcl Special Variables . . . . . . . . . . . . . . . . . . . 6
  18. 4. Operators and Expressions . . . . . . . . . . . . . . . . 7
  19. 5. Regular Expressions . . . . . . . . . . . . . . . . . . . 7
  20. 6. Pattern Globbing . . . . . . . . . . . . . . . . . . . . . 8
  21. 7. Control Statements . . . . . . . . . . . . . . . . . . . . 9
  22. 8. File Information . . . . . . . . . . . . . . . . . . . . . 9
  23. 9. Tcl Interpreter Information . . . . . . . . . . . . . . . . 11
  24. 10. Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
  25. 11. Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . 14
  26. 12. Strings and Binary Data . . . . . . . . . . . . . . . . . 15
  27. 13. System Interaction . . . . . . . . . . . . . . . . . . . . 19
  28. 14. File Input/Output . . . . . . . . . . . . . . . . . . . . . 20
  29. 15. Multiple Interpreters . . . . . . . . . . . . . . . . . . . 23
  30. 16. Packages . . . . . . . . . . . . . . . . . . . . . . . . . 24
  31. 17. Namespaces . . . . . . . . . . . . . . . . . . . . . . . 25
  32. 18. Other Tcl Commands . . . . . . . . . . . . . . . . . . 26
  33. 19. Tk Shell . . . . . . . . . . . . . . . . . . . . . . . . . 31
  34. 20. Tk Special Variables . . . . . . . . . . . . . . . . . . . 31
  35. 21. General Tk Widget Information . . . . . . . . . . . . . 31
  36. 22. Widget Scroll Commands . . . . . . . . . . . . . . . . 34
  37. 23. Entry Validation . . . . . . . . . . . . . . . . . . . . . 35
  38. 24. The Canvas Widget . . . . . . . . . . . . . . . . . . . 36
  39. 25. The Entry Widget . . . . . . . . . . . . . . . . . . . . 44
  40. 26. The Listbox Widget . . . . . . . . . . . . . . . . . . . 46
  41. 27. The Menu Widget . . . . . . . . . . . . . . . . . . . . 47
  42. 28. The Text Widget . . . . . . . . . . . . . . . . . . . . . 49
  43. 29. Other Standard Widgets . . . . . . . . . . . . . . . . . 53
  44. 30. Images . . . . . . . . . . . . . . . . . . . . . . . . . . 63
  45. 31. Window Information . . . . . . . . . . . . . . . . . . . 65
  46. 32. The Window Manager . . . . . . . . . . . . . . . . . . 67
  47. 33. Binding and Virtual Events . . . . . . . . . . . . . . . . 69
  48. 34. Geometry Management . . . . . . . . . . . . . . . . . 71
  49. 35. Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
  50. 36. Other Tk Commands . . . . . . . . . . . . . . . . . . . 74
  51. 37. TclX 8.4 . . . . . . . . . . . . . . . . . . . . . . . . . 79
  52. 38. TclX Special Variables and Commands . . . . . . . . . 79
  53. 39. TclX General Commands . . . . . . . . . . . . . . . . 79
  54. 40. TclX Debugging Commands . . . . . . . . . . . . . . . 81
  55. 41. TclX Development Commands . . . . . . . . . . . . . . 81
  56. 42. TclX Unix Access Commands . . . . . . . . . . . . . . 82
  57. 43. TclX File Commands . . . . . . . . . . . . . . . . . . 84
  58. 44. TclX Network Programming Support . . . . . . . . . . 86
  59. 2
  60. Tcl/Tk Reference Guide
  61. 45. TclX File Scanning Commands . . . . . . . . . . . . . 86
  62. 46. TclX Math Commands . . . . . . . . . . . . . . . . . . 86
  63. 47. TclX List Manipulation Commands . . . . . . . . . . . 87
  64. 48. TclX Keyed Lists . . . . . . . . . . . . . . . . . . . . 88
  65. 49. TclX String/Character Commands . . . . . . . . . . . . 88
  66. 50. TclX XPG/3 Message Catalog Commands . . . . . . . . 89
  67. 51. Img 1.2.4 Package . . . . . . . . . . . . . . . . . . . . 90
  68. 52. Tcllib 1.4 . . . . . . . . . . . . . . . . . . . . . . . . . 91
  69. 53. Tktable 2.8 Package . . . . . . . . . . . . . . . . . . . 98
  70. 54. Vu 2.1.0 Package . . . . . . . . . . . . . . . . . . . . . 105
  71. 55. Vim 6.2 if tcl Interface . . . . . . . . . . . . . . . . . 112
  72. Rev. 80.3.1.17
  73. 3
  74. Tcl/Tk Reference Guide
  75. Notes
  76. 4
  77. Tcl/Tk Reference Guide
  78. Conventions
  79. fixed denotes literal text.
  80. this means variable text, i.e. things you must fill in.
  81. word is a keyword, i.e. a word with a special meaning.
  82. [. . . ] denotes an optional part.
  83. 1. Tcl Shell
  84. tclsh [script [arg . . . ]]
  85. Tclsh reads Tcl commands from its standard input or from file script and evaluates
  86. them.
  87. Without arguments, tclsh runs interactively, sourcing the file .tclshrc (if it exists)
  88. before reading the standard input. With arguments, script is the name of a file to
  89. source and any additional arguments will become the value of the Tcl variable
  90. $argv.
  91. 2. Basic Tcl Language Features
  92. ; or newline statement separator
  93. \ statement continuation if last character in line
  94. # comments out rest of line (if first non-whitespace character)
  95. var simple variable
  96. var(index) associative array variable
  97. var(i,j) multi-dimensional array variable
  98. $var variable substitution (also ${var}xyz)
  99. [expr 1+2] command substitution
  100. \char backslash substitution (see below)
  101. "hello $a" quoting with substitution
  102. {hello $a} quoting with no substitution (deferred substitution)
  103. The only data type in Tcl is a string. However, some commands will interpret
  104. arguments as numbers/boolean in which case the formats are
  105. Integer: 123 0xff(hex) 0377 (octal).
  106. Floating Point: 2.1 3. 6e4 7.91e+16
  107. Boolean: true false 0 1 yes no
  108. Tcl makes the following backslash substitutions:
  109. \a audible alert (0x7) \space space
  110. \b backspace (0x8) \newline space
  111. \f form feed (0xC) \ddd octal value (d=07)
  112. \n newline (0xA) \xdd hexadecimal value (d=09, a–f)
  113. \r carriage return (0xD) \udddd hexadecimal unicode value (d=09, a–f)
  114. \t horizontal tab (0x9) \c replace ‘\c’ with ‘c’
  115. \v vertical tab (0xB) \\ a backslash
  116. 5
  117. Tcl/Tk Reference Guide
  118. 3. Tcl Special Variables
  119. argc Number of command line arguments, not including the
  120. name of the script file.
  121. argv Tcl list (possibly empty) of command line arguments.
  122. argv0 Name of script or command interpreter.
  123. auto_noexec If set to any value, then unknown will not attempt to
  124. auto-exec any commands.
  125. auto_noload If set to any value, then unknown will not attempt to
  126. auto-load any commands.
  127. auto_path List of directories to search during auto-load operations.
  128. $env(TCLLIBPATH)overrides the default list.
  129. env Array where each element name is an enviroment variable.
  130. errorCode Error code information from the last Tcl error. A list
  131. containing class [code [msg]].
  132. errorInfo Describes the stack trace of the last Tcl error.
  133. tcl_library Directory containing library of standard Tcl scripts. Value is
  134. returned by [info library]. $env(TCL_LIBRARY)
  135. overrides the built-in value.
  136. tcl_libPath List of all possible locations for Tcl packages.
  137. tcl_interactive
  138. True if command interpreter is running interactively.
  139. tcl_patchLevel Integer specifying current patch level for Tcl.
  140. tcl_pkgPath List of directories to search for installed packages. Value is
  141. added to $auto_path.
  142. tcl_platform Array with elements byteOrder, debug (if compiled
  143. with debugging enabled), machine, os, osVersion,
  144. platform, threaded(if compiled with threads
  145. enabled), user, and wordSize.
  146. tcl_precision Number of significant digits to retain when converting
  147. floating-point numbers to strings (default 12).
  148. tcl_prompt1 A script which, when evaluated, outputs the main command
  149. prompt during interactive execution of tclsh or wish.
  150. tcl_prompt2 A script which, when evaluated, outputs the secondary
  151. command prompt during interactive execution of tclsh or
  152. wish.
  153. tcl_rcFileName Name of script to source upon start-up of an interactive
  154. tclsh or wish.
  155. tcl_traceCompile
  156. Level of tracing info output during bytecode compilation: 0
  157. for none, 1 for summary line, or 2 for byte code instructions.
  158. tcl_traceExec Level of tracing info output during bytecode execution: 0
  159. for none, 1 for summary line, 2 and 3 for detailed trace.
  160. tcl_wordchars If set, a regular expression that controls what are considered
  161. to be “word” characters.
  162. tcl_nonwordchars
  163. If set, a regular expression that controls what are considered
  164. to be “non-word” characters.
  165. tcl_version Current version of Tcl in major.minor form.
  166. 6
  167. Tcl/Tk Reference Guide
  168. 4. Operators and Expressions
  169. The expr command recognizes the following operators, in decreasing order of
  170. precedence:
  171. - ˜ ! unary minus, bitwise NOT, logical NOT
  172. * / % multiply, divide, remainder
  173. + - add, subtract
  174. << >> bitwise shift left, bitwise shift right
  175. < > <= >= boolean comparisons
  176. == != boolean equals, not equals
  177. eq ne boolean string equals, not equals
  178. & bitwise AND
  179. ∧ bitwise exclusive OR
  180. | bitwise inclusive OR
  181. && logical AND
  182. || logical OR
  183. x ? y : z if x != 0, then y, else z
  184. All operators support integers. All support floating point except ˜, %, <<, >>, &,
  185. ,
  186. and |. Boolean operators can also be used for string operands (but note eq and
  187. ne), in which case string comparison will be used. This will occur if any of the
  188. operands are not valid numbers. The &&, ||, and ?: operators have “lazy
  189. evaluation”, as in C.
  190. Possible operands are numeric values, Tcl variables (with $), strings in double
  191. quotes or braces, Tcl comands in brackets, and the following math functions:
  192. abs cos hypot round tanh
  193. acos cosh int sin wide
  194. asin double log sinh
  195. atan exp log10 sqrt
  196. atan2 floor pow srand
  197. ceil fmod rand tan
  198. 5. Regular Expressions
  199. regex* match zero or more of regex
  200. regex+ match one or more of regex
  201. regex? match zero or one of regex
  202. regex{m} match exactly m of regex
  203. regex{m,} match m or more of regex
  204. regex{m,n} match m through n of regex
  205. *? +? ?? {m}? {m,}? {m,n}?
  206. match smallest number of regex rather than longest
  207. regex|regex match either expression
  208. . any single character except newline
  209. ( ) capture group (possibly empty)
  210. (?: ) non-capture group (possibly empty)
  211. ∧ $ match beginning, end of line
  212. (?=regex) (?!regex) match ahead to point where regex begins, does not begin
  213. [abc] [∧abc] match characters in set, not in set
  214. [a-z] [∧a-z] match characters in range, not in range
  215. 7
  216. Tcl/Tk Reference Guide
  217. [:class:] within range, match class character; class is alpha,
  218. upper, lower, digit, xdigit, alnum, print,
  219. blank, space, punct, graph, or cntrl
  220. \d \s \w synonym for [[:digit:]], [[:space:]], [[:alnum:]_]
  221. \D \S \W synonym for [[:digit:]], [[:space:]], [[:alnum:]_]
  222. \c match character c even if special
  223. \cX match control character ∧X
  224. \0 \xhhh match character with value 0, value 0xhhh
  225. \e match ESC
  226. \B synonym for \
  227. \A \Z match beginning, end of string
  228. \m \M match beginning, end of word
  229. \y match beginning or end of word
  230. \Y match at point which is not beginning or end of word
  231. \m back reference to mth group
  232. Meta syntax is specified when the regex begins with a special form.
  233. ***=regex regex is a literal string
  234. (?letters)regex Embedded options:
  235. b regex is a basic regular expression
  236. c case-sensitive matching
  237. e regex is an extended regular expression
  238. i case-insensitive matching (-nocase)
  239. n new-line sensitive matching (-line)
  240. p partial new-line sensitive matching (-linestop)
  241. q rest of regex is a literal
  242. s non-newline sensitive matching (default)
  243. t tight syntax regex
  244. w inverse partial new-line sensitive matching
  245. (-lineanchor)
  246. x expanded syntax regex (-expanded)
  247. 6. Pattern Globbing
  248. ? match any single character
  249. * match zero or more characters
  250. [abc] match set of characters
  251. [a-z] match range of characters
  252. \c match character c
  253. {a,b,. . . } match any of strings a, b, etc.
  254. ˜ home directory (for glob command)
  255. ˜user match user’s home directory (for glob command)
  256. Note: for the glob command, a ‘.’ at the beginning of a file’s name or just after ‘/’
  257. must be matched explicitly and all ‘/’ characters must be matched explicitly.
  258. 8
  259. Tcl/Tk Reference Guide
  260. 7. Control Statements
  261. break Abort innermost containing loop command.
  262. case Obsolete, see switch.
  263. continue
  264. Skip to the next iteration of innermost containing loop command.
  265. exit [returnCode]
  266. Terminate the process, returning returnCode (an integer which defaults to
  267. 0) to the system as the exit status.
  268. for start test next body
  269. Looping command where start, next, and body are Tcl command strings
  270. and test is an expression string to be passed to expr command.
  271. foreach varname list body
  272. The Tcl command string body is evaluated for each item in the string list
  273. where the variable varname is set to the item’s value.
  274. foreach varlist1 list1 [varlist2 list2 . . . ] body
  275. Same as above, except during each iteration of the loop, each variable in
  276. varlistN is set to the current value from listN.
  277. if expr1 [ then ] body1 [ elseif expr2 [ then ] body2 . . . ] [ [ else ] bodyN ]
  278. If expression string expr1 evaluates true, Tcl command string body1 is
  279. evaluated. Otherwise if expr2 is true, body2 is evaluated, and so on. If
  280. none of the expressions evaluate to true then bodyN is evaluated.
  281. return [-code code] [-errorinfo info] [-errorcode value] [string]
  282. Return immediately from current procedure with string as return value.
  283. The code is one of ok (default), error (-errorinfoand
  284. -errorcodeprovide values for the corresponding Tcl variables),
  285. return, break, continue, or integer.
  286. switch [options] string pattern1 body1 [ pattern2 body2 . . . ]
  287. switch [options] string {pattern1 body1 [ pattern2 body2 . . . ] }
  288. The string argument is matched against each of the pattern arguments in
  289. order. The bodyN of the first match found is evaluated. If no match is
  290. found and the last pattern is the keyword default, its bodyN is
  291. evaluated. Possible options are -glob, -regexp, and -exact(default).
  292. while test body
  293. Evaluates the Tcl command string body as long as expression string test
  294. evaluates to true.
  295. 8. File Information
  296. file atime fileName [time]
  297. Query or set time fileName was last accessed as seconds since Jan. 1, 1970.
  298. file attributes fileName [option [value . . . ] ]
  299. Query or set platform-specific attributes of fileName. Options are for UNIX:
  300. -groupid | name, -ownerid | name, -permissionsoctal |
  301. [ugo]?[[+-=][rwxst],[...]]; for Windows -archive,
  302. -hidden, -longname, -readonly, -shortname, -system; and for
  303. MacOS: -creator, -hidden, -readonly, -type.
  304. file channels [pattern]
  305. Returns list of open channels matching glob pattern in current interpreter. If
  306. no pattern is given, returns all channels.
  307. 9
  308. Tcl/Tk Reference Guide
  309. file copy [-force] [- -] source [source . . . ] target
  310. Makes a copy of source under name target. If multiple sources are given,
  311. target must be a directory. Use -force to overwrite existing files.
  312. file delete [-force] [- -] fileName [fileName . . . ]
  313. Removes given files. Use -force to remove non-empty directories.
  314. file dirname fileName
  315. Returns all directory path components of fileName.
  316. file executable fileName
  317. Returns 1 if fileName is executable by user, 0 otherwise.
  318. file exists fileName
  319. Returns 1 if fileName exists (and user can read its directory), 0 otherwise.
  320. file extension fileName
  321. Returns all characters in fileName after and including the last dot.
  322. file isdirectory fileName
  323. Returns 1 if fileName is a directory, 0 otherwise.
  324. file isfile fileName
  325. Returns 1 if fileName is a regular file, 0 otherwise.
  326. file join name [name . . . ]
  327. Joins file names using the correct path separator for the current platform.
  328. file link linkName
  329. Return target of symbolic link linkName.
  330. file link linkName target
  331. Create symbolic link linkName to target.
  332. file link [-hard] linkName [target]
  333. file link [-symbolic] linkName [target]
  334. Create either hard or symbolic link linkName to target.
  335. file lstat fileName varName
  336. Same as file stat except uses the lstat kernel call.
  337. file mkdir dirName [dirName . . . ]
  338. Creates given directories.
  339. file mtime fileName [time]
  340. Query or set time fileName was last modified as seconds since Jan. 1, 1970.
  341. file nativename fileName
  342. Returns the platform-specific name of fileName.
  343. file normalize fileName
  344. Returns normalised path representation for fileName.
  345. file owned fileName
  346. Returns 1 if fileName owned by the current user, 0 otherwise.
  347. file pathtype fileName
  348. Returns one of absolute, relative, or volumerelative.
  349. file readable fileName
  350. Returns 1 if fileName is readable by current user, 0 otherwise.
  351. file readlink fileName
  352. Returns value of symbolic link given by fileName.
  353. file rename [-force] [- -] source [source . . . ] target
  354. Renames file source to target. If target is an existing directory, each source
  355. file is moved there. The -force option forces overwriting of existing files.
  356. file rootname fileName
  357. Returns all the characters in fileName up to but not including last dot.
  358. 10
  359. Tcl/Tk Reference Guide
  360. file separator
  361. Returns path separator for the current platform.
  362. file separator [fileName]
  363. Returns path separator for filesystem containing fileName.
  364. file size fileName
  365. Returns size of fileName in bytes.
  366. file split fileName
  367. Returns list whose elements are the path components of fileName.
  368. file stat fileName varName
  369. Place results of stat kernel call on fileName in variable varName as an array
  370. with elements atime, ctime, dev, gid, ino, mode, mtime, nlink,
  371. size, type, and uid.
  372. file system fileName
  373. Returns two-element list for fileName: filesystem name and type (which may
  374. be null).
  375. file tail fileName
  376. Return all characters in fileName after last directory separator.
  377. file type fileName
  378. Returns type of fileName. Possible values are file, directory,
  379. characterSpecial, blockSpecial, fifo, link, or socket.
  380. file volumes
  381. Returns just ‘/’ on UNIX, list of local drives on Windows, and list of local
  382. and network drives on MacOS.
  383. file writable fileName
  384. Returns 1 if fileName is writable by current user, 0 otherwise.
  385. 9. Tcl Interpreter Information
  386. info args procName
  387. Returns list describing in order the names of arguments to procName.
  388. info body procName
  389. Returns the body of procedure procName.
  390. info cmdcount
  391. Returns the total number of commands that have been invoked.
  392. info commands [pattern]
  393. Returns list of Tcl commands (built-ins and procs) matching glob pattern
  394. (default *). If no pattern is given, returns all commands in current
  395. namespace.
  396. info complete command
  397. Returns 1 if command is a complete Tcl command, 0 otherwise. Complete
  398. means having no unclosed quotes, braces, brackets or array element names
  399. info default procName arg varName
  400. Returns 1 if procedure procName has a default for argument arg and places
  401. the value in variable varName. Returns 0 if there is no default.
  402. info exists varName
  403. Returns 1 if the variable varName exists in the current context, 0 otherwise.
  404. info functions [pattern]
  405. Returns list of math functions matching glob pattern (default *).
  406. info globals [pattern]
  407. Returns list of global variables matching glob pattern (default *).
  408. 11
  409. Tcl/Tk Reference Guide
  410. info hostname
  411. Returns name of computer on which interpreter was invoked.
  412. info level
  413. Returns the stack level of the invoking procedure.
  414. info level number
  415. Returns name and arguments of procedure invoked at stack level number.
  416. info library
  417. Returns name of library directory where standard Tcl scripts are stored.
  418. info loaded [interp]
  419. Returns list describing packages loaded into interp.
  420. info locals [pattern]
  421. Returns list of local variables matching glob pattern (default *).
  422. info nameofexecutable
  423. Returns full pathname of binary from which the application was invoked.
  424. info patchlevel
  425. Returns current patch level for Tcl.
  426. info procs [pattern]
  427. Returns list of Tcl procedures in current namespace matching glob pattern
  428. (default *).
  429. info script [filename]
  430. Query or set name of Tcl script currently being evaluated.
  431. info sharedlibextension
  432. Returns extension used by platform for shared objects.
  433. info tclversion
  434. Returns version number of Tcl in major.minor form.
  435. info vars [pattern]
  436. Returns list of currently-visible variables matching glob pattern (default *).
  437. 10. Lists
  438. concat [arg arg . . . ]
  439. If all args are lists, return a list which is a concatenation of each arg.
  440. Otherwise, return the concatenation of the string value of each arg
  441. (separated by a space) as a single string.
  442. join list [joinString]
  443. Returns string created by joining all elements of list with joinString.
  444. lappend varName [value value . . . ]
  445. Appends each value to the end of the list stored in varName.
  446. lindex list
  447. lindex list {}
  448. Returns list.
  449. lindex list index
  450. Returns value of element at index in list.
  451. lindex list index . . .
  452. lindex list indexList
  453. Each successive index value is used to select the element in the sublist
  454. selected by the previous index value. Return the result.
  455. linsert list index element [element . . . ]
  456. Returns new list formed by inserting given new elements at index in list.
  457. 12
  458. Tcl/Tk Reference Guide
  459. list [arg arg . . . ]
  460. Returns new list formed by using each arg as an element.
  461. llength list
  462. Returns number of elements in list.
  463. lrange list first last
  464. Returns new list from slice of list at indices first through last inclusive.
  465. lreplace list first last [value value . . . ]
  466. Returns new list formed by replacing elements first through last in list with
  467. given values.
  468. lsearch [options] list pattern
  469. Returns index of first element in list that matches pattern (-1 for no match).
  470. Options are
  471. -all return all matching indices or values
  472. -ascii list elements are strings (only meaningful with
  473. -exactor -sorted)
  474. -decreasing list elements are sorted in decreasing order (only
  475. meaningful with -sorted)
  476. -dictionary list elements are compared using dictionary-style
  477. comparisons (only meaningful with -exactor
  478. -sorted)
  479. -exact string match
  480. -glob glob pattern match (default)
  481. -increasing list elements are sorted in increasing order (only
  482. meaningful with -sorted)
  483. -inline return matching value, not index
  484. -integer list elements are compared as integers (only
  485. meaningful with -exactor -sorted)
  486. -not negate the sense of the match
  487. -real list elements are compared as floating point values
  488. (only meaningful with -exactor -sorted)
  489. -regexp regex match
  490. -sorted use sorted list search algorithm (cannot be used with
  491. -globor -regexp)
  492. -startindex start search at index
  493. lset varName newValue
  494. lset varName {} newValue
  495. Replace the value of list varName with newValue. Return the result.
  496. lset varName index newValue
  497. Replace the element at index in list varName with newValue. Return the
  498. result.
  499. lset varName index . . . newValue
  500. lset varName indexList newValue
  501. Replace the element identified by index . . . (or indexList) in list varName
  502. with newValue. Each successive index value is used to select the element in
  503. the sublist selected by the previous index value. Return the result.
  504. lsort [switches] list
  505. Returns new list formed by sorting list according to switches. Switches are
  506. -ascii string comparison (default)
  507. -dictionary like -asciibut ignores case and is number smart.
  508. 13
  509. Tcl/Tk Reference Guide
  510. -indexndx treats each elements as a sub-list and sorts on the
  511. ndxth element
  512. -integer integer comparison
  513. -real floating-point comparison
  514. -increasing sort in increasing order (default)
  515. -decreasing sort in decreasing order
  516. -commandcmd Use cmd which takes two arguments and returns an
  517. integer less than, equal to, or greater than zero
  518. -unique retain only the last duplicate element
  519. split string [splitChars]
  520. Returns a list formed by splitting string at each character in splitChars
  521. (default white-space).
  522. List Indices:
  523. Start at 0. The word end may be used to reference the last element in the
  524. list, and end-integer refers to the last element in the list minus the specified
  525. integer offset.
  526. 11. Arrays
  527. array anymore arrayName searchId
  528. Returns 1 if anymore elements are left to be processed in array search
  529. searchId on arrayName, 0 otherwise.
  530. array donesearch arrayName searchId
  531. Terminates the array search searchId on arrayName.
  532. array exists arrayName
  533. Returns 1 if arrayName is an array variable, 0 otherwise.
  534. array get arrayName
  535. Returns a list where each odd element is an element name and the following
  536. even element its corresponding value.
  537. array names arrayName [mode] [pattern]
  538. Returns list of all element names in arrayName that match pattern. Mode
  539. may be -exact, -glob (default *), or -regexp.
  540. array nextelement arrayName searchId
  541. Returns name of next element in arrayName for the search searchId.
  542. array set arrayName list
  543. Sets values of elements in arrayName for list in array get format.
  544. array size arrayName
  545. Return number of elements in arrayName.
  546. array startsearch arrayName
  547. Returns a search id to use for an element-by-element search of arrayName.
  548. array statistics arrayName
  549. Returns hashtable statistics for arranName.
  550. array unset arrayName [pattern]
  551. Unsets all of the elements in the array that match glob pattern (default *). If
  552. pattern is omitted, the entire array is unset.
  553. parray arrayName [pattern]
  554. Print to standard output the names and values of all element names in
  555. arrayName that match glob pattern (default *.)
  556. 14
  557. Tcl/Tk Reference Guide
  558. 12. Strings and Binary Data
  559. append varName [value value . . . ]
  560. Appends each of the given values to the string stored in varName.
  561. binary format formatString [arg arg . . . ]
  562. Returns a binary string representation of argss composed according to
  563. formatString, a sequence of zero or more field codes each followed by an
  564. optional integer count or *. The possible field codes are:
  565. a chars (null padding) c 8-bit int W 64-bit int (big)
  566. A chars (space padding) s 16-bit int (little) f float
  567. b binary (low-to-high) S 16-bit int (big) d double
  568. B binary (high-to-low) i 32-bit int (little) x nulls
  569. h hex (low-to-high) I 32-bit int (big) X backspace
  570. H hex (high-to-low) w 64-bit int (little) @ absolute position
  571. binary scan string formatString [varName varName . . . ]
  572. Extracts values into varName’s from binary string according to
  573. formatString. Returns the number of values extracted. For integer and
  574. floating point field codes, a list of count values are consumed and stored in
  575. the corresponding varName. Field codes are the same as for binary format
  576. with the additional:
  577. a chars (no trimming) A chars (trimming) x skip forward
  578. format formatString [arg arg . . . ]
  579. Returns a formated string generated in the ANSI C sprintf-like manner.
  580. Place holders have the form %[argpos$][flag][width][.prec][h|l]char
  581. where argpos is an integer, width and prec are integers or *, possible values
  582. for char are:
  583. d signed decimal X unsigned HEX E float (0E0)
  584. u unsigned decimal c int to char g auto float (f or e)
  585. i signed decimal s string G auto float (f or E)
  586. o unsigned octal f float (fixed) % plain %
  587. x unsigned hex e float (0e0)
  588. and possible values for flag are:
  589. - left-justified 0 zero padding # alternate output
  590. + always signed space space padding
  591. The optional trailing h or l truncates the data to 16-bits or expands it to
  592. 64-bits for integer conversions.
  593. regexp [switches] exp string [matchVar] [subMatchVar . . . ]
  594. Returns 1 if the regular expression exp matches part or all of string , 0
  595. otherwise. If specified, matchVar will be set to all the characters in the match
  596. and the following subMatchVar’s will be set to matched parenthesized
  597. subexpressions. Switches are
  598. -about Instead of matching, returns an informational list. The
  599. first element is a subexpression count, the second a
  600. list of property names that describe various attributes
  601. of the regular expression.
  602. -all Match as many times as possible in the string,
  603. returning the total number of matches found. If match
  604. 15
  605. Tcl/Tk Reference Guide
  606. variables are present, they will continue information
  607. for the last match only.
  608. -expanded Enable expanded form of the regular expression.
  609. -indices matchVar and subMatchVar will be set to the start and
  610. ending indices in string of their corresponding match.
  611. -inline Return, as a list, the data that would otherwise be
  612. placed in match variables (which may not be
  613. specified.) If used with -all, the list will be
  614. concatenated at each iteration. For each match
  615. iteration, the command will append the overall match
  616. data, plus one element for each subexpression in the
  617. regular expression.
  618. -line Enable newline-sensitive matching. With this flag,
  619. []’ bracket expressions and ‘.’ never match newline,
  620. ∧’ matches an empty string after any newline in
  621. addition to its normal function, and ‘$’ matches an
  622. empty string before any newline in addition to its
  623. normal function. This flag is equivalent to specifying
  624. both -linestopand -lineanchor.
  625. -lineanchor With this flag, ‘∧’ and ‘$’ match the beginning and
  626. end of a line respectively.
  627. -linestop With this flag,[]’ bracket expressions and ‘.’ stop at
  628. newlines.
  629. -nocase Ignore case in matching.
  630. -startindex An offset into the string to start matching.
  631. regsub [switches] exp string subSpec [varName]
  632. Replaces the first portion of string that matches the regular expression exp
  633. with subSpec and optionally places results in varName. If subSpec contains
  634. a ‘&’ or “\0, then it is replaced in the substitution with the portion of string
  635. that matched exp. If subSpec contains a “\n” then it is replaced in the
  636. substitution with the portion of string that matched the nth parenthesized
  637. subexpression of exp. Returns either count of number of replacements made
  638. if varName was provided or the result of the substitution. Switches are
  639. -all Substitution is performed for each ranges in string
  640. that match.
  641. -expanded Enable expanded form of the regular expression.
  642. -indices matchVar and subMatchVar will be set to the start and
  643. ending indices in string of their corresponding match.
  644. -line Enable newline-sensitive matching. With this flag,
  645. []’ bracket expressions and ‘.’ never match newline,
  646. ∧’ matches an empty string after any newline in
  647. addition to its normal function, and ‘$’ matches an
  648. empty string before any newline in addition to its
  649. normal function. This flag is equivalent to specifying
  650. both -linestopand -lineanchor.
  651. -lineanchor With this flag, ‘∧’ and ‘$’ match the beginning and
  652. end of a line respectively.
  653. -linestop With this flag,[]’ bracket expressions and ‘.’ stop at
  654. newlines.
  655. -nocase Ignore case in matching.
  656. 16
  657. Tcl/Tk Reference Guide
  658. -startindex An offset into the string to start matching.
  659. scan string formatString [varName varName . . . ]
  660. Extracts values into given variables using ANSI C sscanf behavior. Returns
  661. the number of values extracted, or if no varName’s were specified, returns a
  662. list of the data that would otherwise be stored in the variables. Place holders
  663. have the form %[*][width][h|l|L]char where * is for discard, width is an
  664. integer. If the form is %integer$char, then the variable to use is taken from
  665. the argument indicated by the number, where 1 corresponds to the first
  666. varName. If there are any positional specifiers in format then all of the
  667. specifiers must be positional. Possible values for char are:
  668. d decimal e float s string (non-whitespace)
  669. o octal f float [chars] chars in given range
  670. x hex g float [
  671. ∧chars] chars not in given range
  672. u unsigned i integer c char to int
  673. n number scanned
  674. The modifier h is ignored, but l or L scans a 64-bit value for integer
  675. conversions.
  676. string bytelength string
  677. Returns the number of bytes to represent the UTF-8 representation of string
  678. in memory.
  679. string compare [options] string1 string2
  680. Returns -1, 0, or 1, depending on whether string1 is lexicographically less
  681. than, equal to, or greater than string2. Options are -nocaseor -length
  682. integer.
  683. string equal [options] string1 string2
  684. Returns 0 or 1, depending on whether string1 is lexicographically equal to
  685. string2. Options are -nocaseor -lengthinteger.
  686. string first string1 string2 [startIndex]
  687. Return index (-1 if not found) in string2 of first occurrence of string1
  688. starting at startIndex (default 0).
  689. string index string charIndex
  690. Returns for index an integer, the charIndex’th character in string. If index is
  691. end, the last character in string, and if index is end-integer, the last
  692. character minus the specified offset.
  693. string is class [options] string
  694. Returns 1 if string is a valid member of the specified character class, 0
  695. otherwise. If option -strictis specified, then an empty string returns 0,
  696. otherwise 1 on any class. If -failindexvarname is specified then, on
  697. failure, the index in the string where the class was no longer valid will be
  698. stored in varname. Character classes are
  699. alnum Alphabetic or digit character
  700. alpha Alphabetic character
  701. ascii Character in 7-bit ascii range
  702. boolean Any of Tcl boolean forms
  703. control A control character
  704. digit A digit character
  705. double Any of Tcl double forms with optional surrounding
  706. white space; 0 returned for under/overflow with
  707. varname set to -1
  708. false Any Tcl boolean false form
  709. 17
  710. Tcl/Tk Reference Guide
  711. graph Any printing character except space
  712. integer Any of Tcl integer forms with optional surrounding
  713. white space; 0 returned for under/overflow with
  714. varname set to -1
  715. lower A lower case alphabetic character
  716. print Any printing character including space
  717. punct A punctuation character
  718. space A white-space character
  719. true Any Tcl boolean true form
  720. upper A upper case character
  721. wordchar A valid word character
  722. xdigit A digit or letter in the range [a–fA–F]
  723. string last string1 string2 lastIndex
  724. Return index (-1 if not found) in string2 of last occurrence of string1 no
  725. higher than lastIndex (default end).
  726. string length string
  727. Returns the number of characters in string.
  728. string map [-nocase] charMap string
  729. Replaces characters in string based on the key-value pairs in charMap. Each
  730. instance of a key in the string will be replaced with its corresponding value.
  731. string match [-nocase] pattern string
  732. Returns 1 if glob pattern matches string, 0 otherwise.
  733. string range string first last
  734. Returns characters from string at indices first through last inclusive. The
  735. indices are as for string index.
  736. string repeat string count
  737. Returns new string formed by string repeated count times.
  738. string replace string first last [newstring]
  739. Removes characters from string at indices first through last inclusive. If
  740. newstring is supplied, it will replace the removed characters. The indices are
  741. as for string index.
  742. string tolower string [first [last]]
  743. Returns new string formed by converting all chars in string to lower case at
  744. indices first through last inclusive. The indices are as for string index.
  745. string totitle string [first [last]]
  746. Returns new string formed by converting the first character in string to upper
  747. case and the remainder to lower case at indices first through last inclusive.
  748. The indices are as for string index.
  749. string toupper string [first [last]]
  750. Returns new string formed by converting all chars in string to upper case at
  751. indices first through last inclusive. The indices are as for string index.
  752. string trim string [chars]
  753. Returns new string formed by removing from string any leading or trailing
  754. characters present in the set chars (default whitespace).
  755. string trimleft string [chars]
  756. Same as string trim for leading characters only.
  757. string trimright string [chars]
  758. Same as string trim for trailing characters only.
  759. 18
  760. Tcl/Tk Reference Guide
  761. string wordend string index
  762. Returns index of character just after last one in word at index in string.
  763. string wordstart string index
  764. Returns index of first character of word at index in string.
  765. subst [-nobackslashes] [-nocommands] [-novariables] string
  766. Returns result of backslash, command, and variable substitutions on string.
  767. Each may be turned off by switch.
  768. 13. System Interaction
  769. cd [dirName]
  770. Change working directory to dirName.
  771. clock clicks [-milliseconds]
  772. Returns hi-res system-dependent integer time value. If -millisecondsis
  773. specified, then the value is guaranteed to be of millisecond granularity.
  774. clock format clockVal [-formatstring] [-gmt boolean]
  775. Convert integer clockVal to human-readable format defined by string which
  776. recognizes (at least) the following place holders:
  777. %% % %p AM/PM
  778. %a weekday (abbr) %Q Stardate
  779. %A weekday (full) %r locale time; %I:%M:%S %p
  780. %b month (abbr) %R %H:%M
  781. %B month (full) %S seconds (0059)
  782. %C century (19 or 20) %s seconds since epoch
  783. %d day (0131) %t \t
  784. %D %m/%d/%y %T %H:%M:%S
  785. %e day (131) %U week, Sun–Sat (0052)
  786. %H hour (0023) %u weekday (Mon=1, Sun=7)
  787. %h month (abbr) %V week, Jan 4 is week 1 (0153)
  788. %I hour (0112) %W week, Mon–Sun (0052)
  789. %j day (001366) %w weekday (Sun=0 – Sat=6)
  790. %k hour (023) %x locale date; %m/%d/%y
  791. %l hour (112) %X locale time; %H:%M:%S
  792. %M minute (0059) %y year (0099)
  793. %m month (0112) %Y year (full)
  794. %n \n %Z time zone
  795. %c locale date & time; %a %b %d %H:%M:%S %Y
  796. The default format is ”%a %b %d %H:%M:%S %Z %Y”.
  797. clock scan dateString [-base clockVal] [-gmt boolean]
  798. Convert dateString to an integer clock value. If dateString contains a 24
  799. hour time only, the date given by clockVal is used.
  800. clock seconds
  801. Return current date and time as system-dependent integer value.
  802. exec [-keepnewline] arg [arg . . . ]
  803. Execute subprocess using each arg as word for a shell pipeline and return
  804. results written to standard out, optionally retaining the final newline char.
  805. The following constructs can be used to control I/O flow.
  806. | pipe (stdout)
  807. |& pipe (stdout and stderr)
  808. <fileName stdin from file
  809. 19
  810. Tcl/Tk Reference Guide
  811. <@ fileId stdin from open file
  812. <<value pass value to stdin
  813. >fileName stdout to file
  814. 2>fileName stderr to file
  815. >& fileName stdout and stderr to file
  816. >>fileName append stdout to file
  817. 2>>fileName append stderr to file
  818. >>& fileName stdout and stderr to file
  819. >@ fileId stdout to open file
  820. 2>@ fileId stderr to open file
  821. >&@ fileId stdout and stderr to open file
  822. & run in background
  823. glob [switches] pattern [pattern . . . ]
  824. Returns list of all files in current directory that match any of the given glob
  825. patterns, as interpreted by the given switches. Switches are
  826. -directorydirectory
  827. Search starting in the given directory. May not be
  828. used with -path.
  829. -join The pattern arguments are treated as a single pattern
  830. obtained by joining the arguments with directory
  831. separators.
  832. -nocomplain Allows an empty list to be returned without error.
  833. -pathpathPrefix Search with the given pathPrefix where the rest of the
  834. name matches the given patterns. May not be used
  835. with -directory.
  836. -tails Only return part of file which follows last directory
  837. named in -directoryor -path specification.
  838. -typestypeList Only match files or directories which match typeList,
  839. where the items in the list have two forms (which
  840. may be mixed.)
  841. The first form is: b (block special file), c (character
  842. special file), d (directory), f (plain file), l (symbolic
  843. link), p (named pipe), or s (socket), where multiple
  844. types may be specified in the list. Return all files
  845. which match at least one of the types given.
  846. For the second form, all the types must match. These
  847. are r, w, x as file permissions, and readonly,
  848. hiddenas special permission cases.
  849. pid [fileId]
  850. Return process id of process pipeline fileId if given, otherwise return process
  851. id of interpreter process.
  852. pwd Returns the current working directory.
  853. 14. File Input/Output
  854. close fileId
  855. Close the open file channel fileId.
  856. eof fileId
  857. Returns 1 if an end-of-file has occurred on fileId, 0 otherwise.
  858. 20
  859. Tcl/Tk Reference Guide
  860. fblocked fileId
  861. Returns 1 if last read from fileId exhausted all available input.
  862. fconfigure fileId [option [value]]
  863. Sets and gets options for I/O channel fileId. Options are:
  864. -blockingboolean Whether I/O can block process.
  865. -buffering full|line|none
  866. How to buffer output.
  867. -buffersizebyteSize Size of buffer.
  868. -encodingname
  869. Specify Unicode encoding to name or binary.
  870. -eofcharchar | {inChar outChar}
  871. Sets character to serve as end-of-file marker.
  872. -translationmode | {inMode outMode}
  873. Sets how to translate end-of-line markers.
  874. Modes are auto, binary, cr, crlf, and lf.
  875. For socket channels (read-only settings):
  876. -error
  877. Returns current error status.
  878. -sockname
  879. Returns three element list with address, host name and port number.
  880. -peername
  881. For client and accepted sockets, three element list of peer socket.
  882. For serial device channels:
  883. -modebaud,parity,data,stop
  884. Set baud rate, parity (n, o, e, m or s), data bits, and stop bits of
  885. channel.
  886. -handshaketype
  887. Set handshake control (none, rtsctsor xonxoff).
  888. -queue
  889. Return a list of two integers: current number of bytes in input queue
  890. and output queue.
  891. -timeoutmsec
  892. Set timeout for blocking reads.
  893. -ttycontrol{signal boolean . . . }
  894. Setup the handshake output lines (rts or dtr) permanently or send a
  895. BREAK (break).
  896. -ttystatus
  897. Return list of current modem status and handshake signals: {CTS
  898. boolean DSR boolean RING boolean DCD boolean }
  899. -xchar{xonChar xoffChar}
  900. Set software handshake characters.
  901. fcopy inId outId [-size size] [-commandcallback]
  902. Transfer data to outId from inId until eof or size bytes have been transferred.
  903. If -commandis given, copy occurs in background and runs callback when
  904. finished appending number of bytes copied and possible error message as
  905. arguments.
  906. fileevent fileId readable|writable[script]
  907. Evaluate script when channel fileId becomes readable/writable.
  908. flush fileId
  909. Flushes any output that has been buffered for fileId.
  910. 21
  911. Tcl/Tk Reference Guide
  912. gets fileId
  913. Read and return next line from channel fileId, discarding newline character.
  914. gets fileId varName
  915. Read next line from channel fileId, discarding newline character, into
  916. varName. Return count of characters read, or -1 if end-of-file.
  917. open item [access [perms]]
  918. Open item (a file, serial port or command pipeline) and return its channel id.
  919. A command pipeline (the first character of item is ‘|’) is a list as described
  920. for exec. If a new file is created, its permission are set to the conjunction of
  921. perms (default 0666) and the process umask. The first form of access may be
  922. r Read only. File must exist.
  923. r+
  924. Read and write. File must exist.
  925. w Write only. Truncate if exists.
  926. w+
  927. Read and write. Truncate if exists.
  928. a Write only. File must exist. Access position at end.
  929. a+
  930. Read and write. Access position at end.
  931. The second form of access may be a list containing any of the following
  932. flags (although one of the flags must be either RDONLY, WRONLYor RDWR.)
  933. RDONLY Open the file for reading only.
  934. WRONLY Open the file for writing only.
  935. RDWR Open the file for both reading and writing.
  936. APPEND Set the file pointer to the end of the file prior to each write.
  937. CREAT Create the file if it doesn’t already exist.
  938. EXCL If CREATis also specified, an error is returned if the file
  939. already exists.
  940. NOCTTY Prevent the terminal device from becoming the controlling
  941. terminal of the process.
  942. NONBLOCK Prevents the process from blocking while opening the file,
  943. and possibly in subsequent I/O operations.
  944. TRUNC If the file exists it is truncated to zero length.
  945. puts [-nonewline] [fileId] string
  946. Write string to fileId (default stdout) optionally omitting newline char.
  947. read [-nonewline] fileId
  948. Read all remaining bytes from fileId, optionally discarding last character if it
  949. is a newline.
  950. read fileId numBytes
  951. Read numBytes bytes from fileId.
  952. seek fileId offset [origin]
  953. Change current access position on fileId to offset bytes from origin which
  954. may be start(default), current, or end.
  955. socket [option . . . ] host port
  956. Open a client-side TCP socket to server host on port (integer or service
  957. name). Options are:
  958. -myaddraddr
  959. Set network address of client (if multiple available).
  960. -myportport Set connection port of client (if different from server).
  961. 22
  962. Tcl/Tk Reference Guide
  963. -async Make connection asynchronous.
  964. socket -servercommand [-myaddraddr] port
  965. Open server TCP socket on port (integer or service name) invoking
  966. command once connected with three arguments: the channel, the address,
  967. and the port number. If port is zero, the operating system will choose a port
  968. number.
  969. tell fileId
  970. Return current access position in fileId.
  971. 15. Multiple Interpreters
  972. interp alias srcPath srcCmd
  973. Returns list whose elements are the targetCmd and args associated with the
  974. alias srcCmd in interpreter srcPath.
  975. interp alias srcPath srcCmd {}
  976. Deletes the alias srcCmd in interpreter srcPath.
  977. interp alias srcPath srcCmd targetPath targetCmd [arg . . .]
  978. Creates an alias srcCmd in interpreter srcPath which when invoked will run
  979. targetCmd and args in the interpreter targetPath.
  980. interp aliases [path]
  981. Returns list of all aliases defined in interpreter path.
  982. interp create [-safe] [- -] [path]
  983. Creates a slave interpreter (optionally safe) named path.
  984. interp delete path [path . . . ]
  985. Deletes the interpreter(s) path and all its slave interpreters.
  986. interp eval path arg [arg . . .]
  987. Evaluates concatenation of args as command in interpreter path.
  988. interp exists path
  989. Returns 1 if interpreter path exists, 0 otherwise.
  990. interp expose path hiddenCmd [exposedCmd]
  991. Make hiddenCmd in interpreter path exposed (optionally as exposedCmd).
  992. interp hide path exposedCmd [hiddenCmd]
  993. Make exposedCmd in interpreter path hidden (optionally as hiddenCmd).
  994. interp hidden path
  995. Returns list of hidden commands in interpreter path.
  996. interp invokehidden path [-global] hiddenCmd [arg . . . ]
  997. Invokes hiddenCmd with specified args in interpreter path (at the global
  998. level if -global is given).
  999. interp issafe [path]
  1000. Returns 1 if interpreter path is safe, 0 otherwise.
  1001. interp marktrusted [path]
  1002. Marks interpreter path as trusted.
  1003. interp recursionlimit path [newLimit]
  1004. Queries or sets recursion limit (default 1000) for interpreter path.
  1005. interp share srcPath fileId destPath
  1006. Arranges for I/O channel fileId in interpreter srcPath to be shared with
  1007. interpreter destPath.
  1008. interp slaves [path]
  1009. Returns list of names of all slave interpreters of interpreter path.
  1010. 23
  1011. Tcl/Tk Reference Guide
  1012. interp target path alias
  1013. Returns Tcl list describing target interpreter of alias in interpreter path.
  1014. interp transfer srcPath fileId destPath
  1015. Moves I/O channel fileId from interpreter srcPath to destPath.
  1016. For each slave interpreter created, a new Tcl command is created by the same name
  1017. in its master. This command has the alias, aliases, eval, expose, hide, hidden,
  1018. invokehidden, issafe, marktrusted and recursionlimit subcommands like
  1019. interp, but without the srcPath and path arguments (they default to the slave itself)
  1020. and without the targetPath argument (it defaults to the slave’s master).
  1021. A safe interpreter is created with the following commands exposed:
  1022. after eval info package string
  1023. append expr interp pid subst
  1024. array fblocked join proc switch
  1025. binary fcopy lappend puts tell
  1026. break fileevent lindex read time
  1027. case flush linsert regexp trace
  1028. catch for list regsub unset
  1029. clock foreach llength rename update
  1030. close format lrange return uplevel
  1031. concat gets lreplace scan upvar
  1032. continue global lsearch seek variable
  1033. eof if lsort set vwait
  1034. error incr namespace split while
  1035. A safe interpreter is created with the following commands hidden:
  1036. cd exit glob open socket
  1037. encoding fconfigure load pwd source
  1038. exec file
  1039. The following support procedures are also hidden:
  1040. auto_exec_ok auto_import auto_load
  1041. auto_load_index auto_qualify unknown
  1042. The $env variable is also not present in a safe interpreter.
  1043. 16. Packages
  1044. package forget package . . .
  1045. Remove all info about each package from interpreter.
  1046. package ifneeded package version [script]
  1047. Tells interpreter that if version version of package, evaluating script will
  1048. provide it.
  1049. package names
  1050. Returns list of all packages in the interpreter that are currently provided or
  1051. have an ifneeded script available.
  1052. package provide package [version]
  1053. Tells interpreter that package version is now provided. Without version, the
  1054. currently provided version of package is returned.
  1055. package require [-exact] package [version]
  1056. Tells interpreter that package must be provided. Only packages with
  1057. versions equal to or later than version (if provided) are acceptable. If
  1058. -exactis specified, the exact version specified must be provided.
  1059. package unknown [command]
  1060. Specifies a last resort Tcl command to provide a package which have append
  1061. as its final two arguments the desired package and version.
  1062. 24
  1063. Tcl/Tk Reference Guide
  1064. package vcompare version1 version2
  1065. Returns -1 if version1 is earlier than version2, 0 if equal, and 1 if later.
  1066. package versions package
  1067. Returns list of all versions numbers of package with an ifneeded script.
  1068. package vsatisfies version1 version2
  1069. Returns 1 if version2 scripts will work unchanged under version1, 0
  1070. otherwise.
  1071. pkg_mkIndex [switches] directory [pattern . . . ]
  1072. Build the pkgIndex.tclfile for automatic loading of packages. Each
  1073. glob pattern (default *.tcl *.[info sharedlibextension]
  1074. selects script or binary files in directory. Switches are:
  1075. -direct (Default) The generated index will implement direct loading
  1076. of the package upon package require.
  1077. -lazy The generated index will delay loading until the use of one
  1078. of the commands provided by the package,
  1079. -loadpkgPat
  1080. The index process will pre-load any packages that exist in
  1081. the current interpreter and match glob pkgPat into the slave
  1082. interpreter used to generate the index.
  1083. -verbose Generate output during the indexing process.
  1084. ::pkg::create -name pkgName -versionversion options . . .
  1085. Create appropriate package ifneeded command for version version of
  1086. package pkgName. Options are:
  1087. -loadfilespecList
  1088. A binary library that must be loaded. The filespecList
  1089. contains one or two elements: the first is the name of the file
  1090. to load, the second (optional) is a list of commands supplied
  1091. by loading that file.
  1092. -sourcefilespecList
  1093. A Tcl library that must be sourced. The filespecList contains
  1094. one or two elements: the first is the name of the file to load,
  1095. the second (optional) is a list of commands supplied by
  1096. loading that file.
  1097. 17. Namespaces
  1098. namespace children [namespace] [pattern]
  1099. Returns list of child namespaces belonging to namespace (defaults to
  1100. current) which match pattern (default *).
  1101. namespace code script
  1102. Returns new script string which when evaluated arranges for script to be
  1103. evaluated in current namespace. Useful for callbacks.
  1104. namespace current
  1105. Returns fully-qualified name of current namespace.
  1106. namespace delete [namespace . . . ]
  1107. Each given namespace is deleted along with their child namespaces,
  1108. procedures, and variables.
  1109. namespace eval namespace arg [arg . . . ]
  1110. Activates namespace and evaluates concatenation of args’s inside it.
  1111. 25
  1112. Tcl/Tk Reference Guide
  1113. namespace exists namespace
  1114. Returns 1 if namespace is a valid namespace in the current context, returns 0
  1115. otherwise.
  1116. namespace export [-clear] [pattern . . . ]
  1117. Adds to export list of current namespace all commands that match given
  1118. pattern’s. If -clear is given, the export list is first emptied.
  1119. namespace forget [namespace::pattern . . . ]
  1120. Removes from current namespace any previously imported commands from
  1121. namespace that match pattern.
  1122. namespace import [-force] [namespace::pattern . . . ]
  1123. Imports into current namespace commands matching pattern from
  1124. namespace. The -force option allows replacing of existing commands.
  1125. namespace inscope namespace listArg [arg . . . ]
  1126. Activates namespace (which must already exist) and evaluates inside it the
  1127. result of lappend of arg’s to listArg.
  1128. namespace origin command
  1129. Returns fully-qualified name of imported command.
  1130. namespace parent [namespace]
  1131. Returns fully-qualified name of parent namespace of namespace.
  1132. namespace qualifiers string
  1133. Returns any leading namespace qualifiers in string.
  1134. namespace tail string
  1135. Returns the simple name (strips namespace qualifiers) in string.
  1136. namespace which [-command|-variable] name
  1137. Returns fully-qualified name of the command (or as variable, if -variable
  1138. given) name in the current namespace. Will look in global namespace if not
  1139. in current namespace.
  1140. variable [name value . . . ] name [value]
  1141. Creates one or more variables in current namespace (if name is unqualified)
  1142. initialized to optionally given values. Inside a procedure and outside a
  1143. namespace eval, a local variable is created linked to the given namespace
  1144. variable.
  1145. 18. Other Tcl Commands
  1146. after ms [arg1 arg2 arg3 . . .]
  1147. Arrange for command (concat of args) to be run after ms milliseconds have
  1148. passed. With no args, program will sleep for ms milliseconds. Returns the id
  1149. of the event handler created.
  1150. after cancel id|arg1 arg2 . . .
  1151. Cancel previous after command either by command or the id returned.
  1152. after idle [arg1 arg2 arg3 . . .]
  1153. Arrange for command (concat of args) to be run later when Tk is idle.
  1154. Returns the id of the event handler created.
  1155. after info [id]
  1156. Returns information on event handler id. With no id, returns a list of all
  1157. existing event handler ids.
  1158. auto_execok execFile
  1159. Returns full pathname if an executable file by the name execFile exists in
  1160. user’s PATH, empty string otherwise.
  1161. 26
  1162. Tcl/Tk Reference Guide
  1163. auto_load command
  1164. Attempts to load definition for cmd by searching $auto_pathand
  1165. $env(TCLLIBPATH)for a tclIndex file which will inform the interpreter
  1166. where it can find command’s definition.
  1167. auto_mkindex directory pattern [pattern . . . ]
  1168. Generate a tclIndex file from all files in directory that match glob patterns.
  1169. auto_reset
  1170. Destroys cached information used by auto_execok and auto_load.
  1171. bgerror message
  1172. User defined handler for background Tcl errors. Default exists for Tk which
  1173. posts a dialog box containing the error message with an application
  1174. configurable button (default is to save the stack trace to a file.) This behavior
  1175. can be redefined with the global options:
  1176. *ErrorDialog.function.text buttonText
  1177. *ErrorDialog.function.command tclProc
  1178. If selected, tclProc is called with one argument: the text of the stack trace. If
  1179. either of these options is set to the empty string, then the additional button
  1180. will not be displayed in the dialog.
  1181. catch script [varName]
  1182. Evaluate script and store results into varName. If there is an error, a
  1183. non-zero error code is returned and an error message stored in varName.
  1184. encoding convertfrom [encoding] data
  1185. Convert data to Unicode from the specified encoding. If encoding is not
  1186. specified, the current system encoding is used.
  1187. encoding convertto [encoding] string
  1188. Convert string from Unicode to the specified encoding. If encoding is not
  1189. specified, the current system encoding is used.
  1190. encoding names
  1191. Returns a list containing the names of all of the encodings that are currently
  1192. available.
  1193. encoding system [encoding]
  1194. Query or set the system encoding.
  1195. error message [info] [code]
  1196. Interrupt command interpretation with an error described in message. Global
  1197. variables errorInfoand errorCodewill be set to info and code.
  1198. eval arg [arg . . . ]
  1199. Returns result of evaluating the concatenation of args’s as a Tcl command.
  1200. expr arg [arg . . . ]
  1201. Returns result of evaluating the concatenation of arg’s as an operator
  1202. expression. See Operators for more info.
  1203. global varName [varName . . . ]
  1204. Declares given varName’s as global variables.
  1205. history add command [exec]
  1206. Adds command to history list, optionally executing it.
  1207. history change newValue [event]
  1208. Replaces value of event (default current) in history with newValue.
  1209. history clear
  1210. Erase the history list and reset event numbers.
  1211. history event [event]
  1212. Returns value of event (default -1) in history.
  1213. 27
  1214. Tcl/Tk Reference Guide
  1215. history info [count]
  1216. Returns event number and contents of the last count events.
  1217. history keep [count]
  1218. Set number of events to retain in history to count.
  1219. history nextid
  1220. Returns number for next event to be recorded in history.
  1221. history redo [event]
  1222. Re-evaluates event (default -1).
  1223. incr varName [increment]
  1224. Increment the integer value stored in varName by increment (default 1).
  1225. load file [pkgName [interp]]
  1226. Load binary code for pkgName (default derived from file name) from file
  1227. (dynamic lib) into interp. The initialization procedure for pkgName is then
  1228. called to incorporate it into interp.
  1229. load {} pkgName [interp]
  1230. Search for statically linked or previously loaded pkgName. The initialization
  1231. procedure for pkgName is then called to incorporate it into interp.
  1232. proc name args body
  1233. Create a new Tcl procedure (or replace existing one) called name where args
  1234. is a list of arguments and body Tcl commands to evaluate when invoked.
  1235. rename oldName newName
  1236. Rename command oldName so it is now called newName. If newName is the
  1237. empty string, command oldName is deleted.
  1238. set varName [value]
  1239. Store value in varName if given. Returns the current value of varName.
  1240. source fileName
  1241. Read file fileName (up to ’∧Z’ character) and evaluate its contents as a Tcl
  1242. script.
  1243. tcl_endOfWord str start
  1244. Return index of the first end-of-word location after start in str.
  1245. tcl_findLibrary basename version patch initScript enVarName varName
  1246. Search for directory containing extension script library (one script of which
  1247. is initScript) setting global varName with the result and sourcing initScript.
  1248. If varName is not preset, search for initScript in either directory
  1249. $env(envVarName) or (relative to directory containing info
  1250. nameofexecutable) ../lib/basenameversion, ../../lib/basenameversion,
  1251. ../library, ../../library, ../../basename(version|patch)/library or
  1252. ../../../basename(version|patch)/library.
  1253. tcl_startOfNextWord str start
  1254. Return index of the first start-of-word location after start in str.
  1255. tcl_startOfPreviousWord str start
  1256. Return index of the first start-of-word location before start in str.
  1257. tcl_wordBreakAfter str start
  1258. Return index of the first word boundary after start in str.
  1259. tcl_wordBreakBefore str start
  1260. Return index of the first word boundary before start in str.
  1261. time script [count]
  1262. Call interpreter count (default 1) times to evaluate script. Returns string of
  1263. the form “503 microseconds per iteration”.
  1264. 28
  1265. Tcl/Tk Reference Guide
  1266. trace add command procName opsList tclProc
  1267. Arrange for tclProc to be executed whenever command procName is
  1268. modified as specified by opsList, one or more of renameor delete.
  1269. When triggered, tclProc is called with three arguments:
  1270. tclProc oldName newName op
  1271. newName is empty for a deleteoperation.
  1272. trace add execution procName opsList tclProc
  1273. Arrange for tclProc to be executed whenever command procName is
  1274. modified as specified by opsList, one or more of enter, leave,
  1275. enterstepor leavestep. When triggered, tclProc is called with
  1276. arguments:
  1277. tclProc command [code result] op
  1278. command is the complete command being executed. For enterand
  1279. enterstep, execution can be prevented by deleting command. For leave
  1280. and leavestep, code is the result code and result is the result string.
  1281. trace add variable varName opsList tclProc
  1282. Arrange for tclProc to be executed whenever varName is accessed as
  1283. specified by opsList, one or more of array, unset, read or write.
  1284. When triggered, tclProc is called with three arguments:
  1285. tclProc name1 name2 op
  1286. Name1 and name2 give the name(s) for the variable being accessed: if a
  1287. scalar or if an entire array is being deleted and the trace was registered on
  1288. the overall array then name1 is the variable’s name and name2 is empty; if
  1289. the variable is an array element then name1 is the array name and name2 is
  1290. the index into the array. Op indicates what operation is being performed on
  1291. the variable as defined above.
  1292. trace info type name
  1293. Return list for each trace type (command, execution or variable) set on
  1294. procName. Each element of the list is the opsList and tclProc associated
  1295. with the trace.
  1296. trace remove type procName opsList tclProc
  1297. Remove the trace type (command, execution or variable) set on procName
  1298. for the operations opsList with tclProc.
  1299. trace variable varName ops tclProc
  1300. Obsolete. Same as trace add variable varName ops tclProc.
  1301. trace vdelete varName ops tclProc
  1302. Obsolete. Same as trace remove variable varName ops tclProc.
  1303. trace vinfo varName
  1304. Obsolete. Same as trace info variable varName.
  1305. unknown cmdName [arg arg . . . ]
  1306. Called when the Tcl interpreter encounters an undefined command name.
  1307. unset [-nocomplain] [- -] varName [varName . . . ]
  1308. Removes the given variables and arrays from scope. If -nocomplainis
  1309. specified, any possible errors are suppressed.
  1310. update [idletasks]
  1311. Handle pending events. If idletasksis specified, only those operations
  1312. normally deferred until the idle state are processed.
  1313. uplevel [level] arg [arg . . . ]
  1314. Evaluates concatenation of arg’s in the variable context indicated by level,
  1315. 29
  1316. Tcl/Tk Reference Guide
  1317. an integer that gives the distance up the calling stack. If level is preceded by
  1318. #’, then it gives the distance down the calling stack from the global level.
  1319. upvar [level] otherVar myVar [otherVar myVar . . . ]
  1320. Makes myVar in local scope equivalent to otherVar at context level (see
  1321. uplevel) so they share the same storage space.
  1322. vwait varName
  1323. Enter Tcl event loop until global variable varName is modified.
  1324. 30
  1325. Tcl/Tk Reference Guide
  1326. 19. Tk Shell
  1327. wish [arg . . . ]
  1328. wish fileName [arg . . . ]
  1329. Wish reads Tcl commands from its standard input or from file fileName and
  1330. evaluates them.
  1331. With no arguments or with a first argument that starts with ‘-’, wish runs
  1332. interactively, sourcing the file .wishrc (if it exists) before reading the standard
  1333. input. Otherwise, an initial argument fileName is the name of a file to source.
  1334. The name of the application, which is used for purposes such as send commands,
  1335. is taken from the -name option, from fileName, or from the command name by
  1336. which wish was invoked.
  1337. The class of the application, which is used for purposes such as specifying options
  1338. with a resource manager property or .Xdefaults file, is the same as its name except
  1339. that the first letter is capitalized.
  1340. The following command line options are recognized:
  1341. -colormap new
  1342. Use a new private colormap instead of the default screen colormap.
  1343. -displaydisplay
  1344. X11 display for main window.
  1345. -geometrygeometry
  1346. Initial geometry of main window.
  1347. -namename Title to be displayed for the main window, and the name of the
  1348. interpreter for send commands.
  1349. -sync Execute all X server commands synchronously.
  1350. -use id Embed the main window for the application in the window whose
  1351. identifier is id.
  1352. -visualvisual
  1353. Visual to use for the window.
  1354. -- All remaining arguments become the value of $argv.
  1355. 20. Tk Special Variables
  1356. geometry The value of the -geometry command line option.
  1357. tk_library Directory containing library of standard Tk scripts.
  1358. tk_patchLevel Integer specifying current patch level for Tk.
  1359. tk::Priv Array containing information private to standard Tk
  1360. scripts.
  1361. tk_strictMotif When non-zero, Tk tries to adhere to Motif look-and-feel
  1362. as closely as possible.
  1363. tk_textRedraw Set by text widgets when they have debugging turned on.
  1364. tk_textRelayout
  1365. tk_version Current version of Tk in major.minor form.
  1366. 21. General Tk Widget Information
  1367. All widget are created with
  1368. widget pathname [ option1 value1 [ option2 . . . ] ]
  1369. 31
  1370. Tcl/Tk Reference Guide
  1371. where widget is the Tcl command corresponding to the class of widget desired (eg.
  1372. button) and pathname is a string which will be used to identify the newly created
  1373. widget. In general, a widget name is the concatenation of its parent’s name
  1374. followed by a period (unless the parent is the root window ‘.’) and a string
  1375. containing no periods (eg. .mainframe.btnframe.btn1).
  1376. Widget configuration options may be passed in the creation command. Options
  1377. begin with a ‘-’ and are always followed by a value string. After creation, options
  1378. may be changed using the configure widget command
  1379. pathname configure option1 value1 [ option2 . . . ]
  1380. and queried using the cget command
  1381. pathname cget option
  1382. Some of the widget options which multiple widgets support are described here for
  1383. brevity. For options that take screen units, values are in pixels unless an optional
  1384. one letter suffix modifier is present — c (cm), i (inch), m (mm), or p (points).
  1385. -activebackgroundcolor
  1386. Background color of widget when it is active.
  1387. A color is any of the valid names for a color defined in the color database, or
  1388. a specification of the red, green and blue intensities in the form:
  1389. #RGB #RRGGBB #RRRGGGBBB #RRRRGGGGBBBB
  1390. Each R, G, or B represents a single hexadecimal digit. The four forms permit
  1391. colors to be specified with 4-bit, 8-bit, 12-bit or 16-bit values. When fewer
  1392. than 16 bits are provided for each color, they represent the most significant
  1393. bits of the color. For example, #3a7 is the same as #3000a0007000.
  1394. -activeborderwidthwidth
  1395. Width in screen units of widget border when it is active.
  1396. -activeforegroundcolor
  1397. Foreground color of widget when it is active.
  1398. -activestylestyle
  1399. The style in which to draw the active element. One of dotbox, none or
  1400. underline(default).
  1401. -anchoranchorPos
  1402. How information is positioned inside widget. Valid anchorPos values are n,
  1403. ne, e, se, s, sw, w, nw, and center.
  1404. -backgroundcolor
  1405. Background color of widget in normal state (Abbrev: -bg).
  1406. -bitmapbitmap
  1407. Bitmap to display in the widget (error, gray12, gray25,
  1408. gray50, gray75, hourglass, info, questhead,
  1409. question, warning, @filename).
  1410. -borderwidthwidth
  1411. Width in screen units of widget border in normal state (Abbrev: -bd).
  1412. -commandtclCommand
  1413. Tcl command to evaluate when widget is invoked.
  1414. -cursorcursor
  1415. Cursor to display when mouse pointer is in widget. Valid formats:
  1416. name [fgColor [bgColor]
  1417. Name of cursor from /usr/include/X11/cursorfont.h.
  1418. @sourceName maskName fgColor bgColor
  1419. Get source and mask bits from files sourceName and maskName.
  1420. 32
  1421. Tcl/Tk Reference Guide
  1422. @sourceName fgColor
  1423. Get source bits from file sourceName (background transparent).
  1424. -disabledbackgroundcolor
  1425. Background color of widget when it is disabled. Use default if color is the
  1426. empty string.
  1427. -disabledforegroundcolor
  1428. Foreground color of widget when it is disabled. Use default if color is the
  1429. empty string.
  1430. -exportselectionboolean
  1431. Whether or not a selection in the widget should also be the X selection.
  1432. -fontfont
  1433. Font to use when drawing text inside the widget.
  1434. -foregroundcolor
  1435. Foreground color of widget in normal state (Abbrev: -fg).
  1436. -heightheight|textChars
  1437. Height of widget. Units depend on widget.
  1438. -highlightbackgroundcolor
  1439. Color of the rectangle drawn around the widget when it does not have the
  1440. input focus.
  1441. -highlightcolorcolor
  1442. Color of the rectangle drawn around the widget when it has the input focus.
  1443. -highlightthicknesswidth
  1444. Width in screen units of highlight rectangle drawn around widget when it
  1445. has the input focus.
  1446. -imageimage
  1447. Image to display in the widget (see Images).
  1448. -insertbackgroundcolor
  1449. Color to use as background in the area covered by the insertion cursor.
  1450. -insertborderwidthwidth
  1451. Width in screen units of border to draw around the insertion cursor.
  1452. -insertofftimemilliseconds
  1453. Time the insertion cursor should remain “off” in each blink cycle.
  1454. -insertontimemilliseconds
  1455. Time the insertion cursor should remain “on” in each blink cycle.
  1456. -insertwidthwidth
  1457. Width in screen units of the insertion cursor.
  1458. -jumpboolean
  1459. Whether to notify scrollbars and scales connected to the widget to delay
  1460. updates until mouse button is released.
  1461. -justify left|center|right
  1462. How multiple lines line up with each other.
  1463. -orient horizontal|vertical
  1464. Which orientation widget should use in layout.
  1465. -padxwidth
  1466. Extra space in screen units to request for the widget in X-direction.
  1467. -padyheight
  1468. Extra space in screen units to request for the widget in Y-direction.
  1469. -readonlybackgroundcolor
  1470. Background color to use when the widget state is readonly. Use default if
  1471. color is the empty string.
  1472. 33
  1473. Tcl/Tk Reference Guide
  1474. -relief flat|groove|raised|ridge|sunken
  1475. 3-D effect desired for the widget’s border.
  1476. -repeatdelaymilliseconds
  1477. Time a button or key must be held down before it begins to auto-repeat.
  1478. -repeatintervalmilliseconds
  1479. Time between auto-repeats once action has begun.
  1480. -selectbackgroundcolor
  1481. Background color to use when displaying selected items.
  1482. -selectborderwidthwidth
  1483. Width in screen units of border to draw around selected items.
  1484. -selectforegroundcolor
  1485. Foreground color to use when displaying selected items.
  1486. -setgridboolean
  1487. Whether this widget controls the resizing grid for its toplevel window.
  1488. -statestate
  1489. Current state of widget: normal, disabled, active(for button-type
  1490. widgets), or readonly(for entry or spinbox widgets.)
  1491. -takefocusfocusType
  1492. If 0 or 1, signals that the widget should never or always take the focus. If
  1493. empty, Tk decides. Otherwise, evaluates focusType as script with the widget
  1494. name appended as argument. The return value of the script must be 0, 1 or
  1495. empty.
  1496. -textstring
  1497. Text to be displayed inside the widget.
  1498. -textvariablevariable
  1499. Variable which contains a text string to be displayed inside the widget.
  1500. -troughcolorcolor
  1501. Color to use for the rectangular trough areas in widget.
  1502. -underlineindex
  1503. Integer index of a character to underline in the widget.
  1504. -widthwidth|textChars
  1505. Width of widget. Units depend on widget.
  1506. -wraplengthlength
  1507. Maximum line length in screen units for word-wrapping.
  1508. -xscrollcommandcmdPrefix
  1509. Prefix for a command used to communicate with horizontal scrollbars.
  1510. -yscrollcommandcmdPrefix
  1511. Prefix for a command used to communicate with vertical scrollbars.
  1512. 22. Widget Scroll Commands
  1513. The Canvas, Listbox and Text widgets support the following scrolling commands.
  1514. The Entry and Spinbox widgets support the xview command and the scan
  1515. command with the y coordinate dropped.
  1516. widget scan mark x y
  1517. Records x and y as widget’s current view anchor.
  1518. widget scan dragto x y [gain]
  1519. Shift the view by gain (default 10) times the difference between the
  1520. coordinates x and y and the current view anchor coordinates.
  1521. 34
  1522. Tcl/Tk Reference Guide
  1523. widget xview
  1524. Return a two element list specifying the fraction of the horizontal span of the
  1525. widget at the left and right edges of the window.
  1526. widget xview moveto fraction
  1527. Adjust the view in the window so that fraction of the total width of the
  1528. widget is off-screen to the left.
  1529. widget xview scroll number units|pages
  1530. Shift the view by number one-tenths (unit) or nine-tenths (pages) the
  1531. window’s width in the horizontal direction.
  1532. widget yview
  1533. Return a two element list specifying the fraction of the vertical span of the
  1534. widget at the top and bottom edges of the window.
  1535. widget yview moveto fraction
  1536. Adjust the view in the window so that fraction of the total height of the
  1537. widget is off-screen to the top.
  1538. widget yview scroll number units|pages
  1539. Shift the view by number one-tenths (unit) or nine-tenths (pages) the
  1540. window’s height in the vertical direction.
  1541. The Text Widget also supports the following:
  1542. text yview [-pickplace] index
  1543. Changes view of widget’s window to make character at index visible. If
  1544. -pickplaceis specified, index will appear at the top of the window.
  1545. The Entry (xview only), Listbox and Spinbox (xview only) Widgets also support
  1546. the following:
  1547. widget xview index
  1548. Adjusts view so that character position index is at left edge.
  1549. widget yview index
  1550. Adjusts view so that element at index is at top of window.
  1551. 23. Entry Validation
  1552. The Entry and Spinbox widgets support entry validation with the use of the
  1553. -validate, -validatecommandand -invalidcommandoptions.
  1554. The validateCommand will be evaluated according to the -validatemode as
  1555. follows:
  1556. none No validation will occur.
  1557. focus Evaluate validateCommand when the entry receives or loses focus.
  1558. focusin Evaluate validateCommand when the entry receives focus.
  1559. focusout Evaluate validateCommand when the entry loses focus.
  1560. key Evaluate validateCommand when the entry is edited.
  1561. all Evaluate validateCommand for all above conditions.
  1562. It is possible to perform percent substitutions on validateCommand and
  1563. invalidCommand, just as you would in a bind script. The following substitutions
  1564. are recognized:
  1565. %d Type of action: 1 for insert, 0 for delete, or -1 for focus, forced or
  1566. textvariable validation.
  1567. %i Index of char string to be inserted/deleted if present, otherwise -1.
  1568. %P The value of the entry should edition occur.
  1569. %s The current value of entry before edition.
  1570. 35
  1571. Tcl/Tk Reference Guide
  1572. %S The text string being inserted/deleted, if any.
  1573. %v The type of validation currently set.
  1574. %V The type of validation that triggered the callback: key, focusin,
  1575. focusoutor forced.
  1576. %W The name of the entry widget.
  1577. 24. The Canvas Widget
  1578. Canvas Options
  1579. -background -insertbackground -selectborderwidth
  1580. -borderwidth -insertborderwidth -selectforeground
  1581. -cursor -insertofftime -takefocus
  1582. -height -insertontime -width
  1583. -highlightbackground -insertwidth -xscrollcommand
  1584. -highlightcolor -relief -yscrollcommand
  1585. -highlightthickness -selectbackground
  1586. -closeenoughfloat
  1587. How close the mouse cursor must be to an item before it is considered to be
  1588. “inside” the item.
  1589. -confineboolean
  1590. Whether it is allowable to set the canvas’s view outside the scroll region.
  1591. -scrollregioncorners
  1592. List of four coordinates describing the left, top, right, and bottom of a
  1593. rectangular scrolling region.
  1594. -xscrollincrementdistance
  1595. Specifies the increment for horizontal scrolling in screen units.
  1596. -yscrollincrementdistance
  1597. Specifies the increment for vertical scrolling in screen units.
  1598. Coordinates and distances are specified in screen units which are floating point
  1599. numbers optionally suffixed with a scale letter. Examples: 5 (pixel), 2.2i (inch),
  1600. 4.1c (cm), 3m (mm), 21p (pts, 1/72 inch)
  1601. Larger y-coordinates refer to points lower on the screen.
  1602. Larger x-coordinates refer to points farther to the right.
  1603. Coordinate lists:
  1604. The list of coordinates may be specified either as a single Tcl list, or
  1605. as a sequence of discrete elements.
  1606. Tag or id: An id is the integer assigned when an item is created while a tag is
  1607. any non-integer form. Tags may be associated with multiple items. A
  1608. tagOrId may be a logical expression using operators ’&&’, ’||’, ’∧’,
  1609. !and parenthesized subexpressions.
  1610. Tags: current
  1611. Character indices:
  1612. charIndex, end, insert, sel.first, sel.last, @x,y
  1613. Line/polygon indices:
  1614. evenNumber, end, insert, sel.first, sel.last, @x,y
  1615. Dash patterns:
  1616. 36
  1617. Tcl/Tk Reference Guide
  1618. intList Each element represents the number of pixels of a line segment. The
  1619. odd segments are drawn using the outlinecolor, the others are
  1620. transparent.
  1621. charString Only the characters [.,-_ ] are supported. The space can be used to
  1622. enlarge the space between other line elements. Equivalence of
  1623. characters to intList:
  1624. ’.’ 2 4
  1625. ,4 4
  1626. ’-’ 6 4
  1627. ’_’ 8 4
  1628. [.,-_] ’ Enlarge 2nd number by factor of 2
  1629. Canvas Commands
  1630. canvas addtag tag searchSpec [arg arg . . . ]
  1631. Add tag to the list of tags associated with each item that satisfy searchSpec.
  1632. See Canvas Search Specs below.
  1633. canvas bbox tagOrId [tagOrId . . . ]
  1634. Returns a list with four elements giving an approximate bounding box for all
  1635. the items named by the tagOrId arguments.
  1636. canvas bind tagOrId [sequence [command]]
  1637. Associates command to be invoked on events specified with sequence with
  1638. the items given by tagOrId.
  1639. canvas canvasx screenx [gridspacing]
  1640. Returns the canvas x-coordinate that is displayed at screen x-coordinate
  1641. screenx possibly rounding to nearest multiple of gridspacing units.
  1642. canvas canvasy screeny [gridspacing]
  1643. Returns the canvas x-coordinate that is displayed at screen y-coordinate
  1644. screeny possibly rounding to nearest multiple of gridspacing units.
  1645. canvas coords tagOrId [x0 y0 . . . ]
  1646. canvas coords tagOrId [coordList]
  1647. Query or modify the coordinates that define an item.
  1648. canvas create type x y [x y . . . ] [option value . . . ]
  1649. canvas create type coordList [option value . . . ]
  1650. Create a new item of type type at specified coordinates and with list options.
  1651. canvas dchars tagOrId first [last]
  1652. For items given by tagOrId, delete the characters in the range given by first
  1653. and last (defaults to first), inclusive.
  1654. canvas delete [tagOrId . . . ]
  1655. Delete each of the items given by each tagOrId.
  1656. canvas dtag tagOrId [tagToDelete]
  1657. Remove tag tagToDelete from the taglist of items given by tagOrId.
  1658. canvas find searchSpec [arg arg . . . ]
  1659. Returns a list of the items that satisfy the specification searchSpec. See
  1660. Canvas Search Specs below.
  1661. canvas focus tagOrId
  1662. Set the focus to the first textual item given by tagOrId.
  1663. canvas gettags tagOrId
  1664. Return a list of the tags associated with the first item given by tagOrId.
  1665. 37
  1666. Tcl/Tk Reference Guide
  1667. canvas icursor tagOrId index
  1668. Set the insertion cursor for the item(s) given by tagOrId to just before the
  1669. character position index .
  1670. canvas index tagOrId index
  1671. Returns a decimal string giving the numerical index within tagOrId
  1672. corresponding to character position index.
  1673. canvas insert tagOrId beforeThis string
  1674. Insert string just before character position beforeThis in items given by
  1675. tagOrId that support textual insertion.
  1676. canvas itemcget tagOrId option
  1677. Returns the value option for the item given by tagOrId.
  1678. canvas itemconfigure tagOrId [option value . . . ]
  1679. Modifies item-specific options for the items given by tagOrId.
  1680. canvas lower tagOrId [belowThis]
  1681. Move the items given by tagOrId to a new position in the display list just
  1682. before the first item given by belowThis.
  1683. canvas move tagOrId xAmount yAmount
  1684. Move the items given by tagOrId in the canvas coordinate space by adding
  1685. xAmount and yAmount to each items x and y coordinates, respectively.
  1686. canvas postscript [option value . . . ]
  1687. Generate a Encapsulated Postscript representation for part or all of the
  1688. canvas. See Canvas Postscript Options below.
  1689. canvas raise tagOrId [aboveThis]
  1690. Move the items given by tagOrId to a new position in the display list just
  1691. after the first item given by aboveThis.
  1692. canvas scale tagOrId xOrigin yOrigin xScale yScale
  1693. Re-scale items given by tagOrId in canvas coordinate space to change the
  1694. distance from xOrigin,yOrigin by a factor of xScale,yScale respectively.
  1695. canvas scan args
  1696. See Widget Scroll Commands above.
  1697. canvas select adjust tagOrId index
  1698. Adjust nearest end of current selection in tagOrId to be at index and set the
  1699. other end to be the new selection anchor.
  1700. canvas select clear
  1701. Clear the selection if it is in the widget.
  1702. canvas select from tagOrId index
  1703. Set the selection anchor in tagOrId to just before the character at index.
  1704. canvas select item
  1705. Return id of the selected item. Returns a empty string if there is none.
  1706. canvas select to tagOrId index
  1707. Set the selection to extend between index and anchor point in tagOrId.
  1708. canvas type tagOrId
  1709. Returns the type of the first item given by tagOrId.
  1710. canvas xview|yview args
  1711. See Widget Scroll Commands above.
  1712. Canvas Search Specifications
  1713. above tagOrId
  1714. Selects the item just after the one given by tagOrId in the display list.
  1715. 38
  1716. Tcl/Tk Reference Guide
  1717. all Selects all the items in the canvas.
  1718. below tagOrId
  1719. Selects the item just before the one given by tagOrId in the display list.
  1720. closest x y [halo] [start]
  1721. Select the topmost, closest item to @x,y that is below start in the display list.
  1722. Any item closer than halo to the point is considered to overlap it.
  1723. enclosed x1 y1 x2 y2
  1724. Selects all the items completely enclosed within x1 y1 x2 y2.
  1725. overlapping x1 y1 x2 y2
  1726. Selects all the items that overlap or are enclosed within x1 y1 x2 y2.
  1727. withtag tagOrId
  1728. Selects all the items given by tagOrId.
  1729. Common Item Options
  1730. -dashpattern
  1731. Dash pattern for the normal state of an item. Default is a solid line.
  1732. -activedashpattern
  1733. Dash pattern for the active state of an item. Default is a solid line.
  1734. -disableddashpattern
  1735. Dash pattern for the disabled state of an item. Default is a solid line.
  1736. -dashoffsetoffset
  1737. Starting offset in pixels into the pattern provided by the -dash option.
  1738. -fillcolor
  1739. Color used to fill item’s area in its normal state.
  1740. -activefillcolor
  1741. Color used to fill item’s area in its active state.
  1742. -disabledfillcolor
  1743. Color used to fill item’s area in its disabled state.
  1744. -outlinecolor
  1745. Color used to draw the item’s outline in its normal state.
  1746. -activeoutlinecolor
  1747. Color used to draw the item’s outline in its active state.
  1748. -disabledoutlinecolor
  1749. Color used to draw the item’s outline in its disabled state.
  1750. -offsetoffset
  1751. The stipple offset of the form x,y or side where side can be n, ne, e, se, s,
  1752. sw, w, nw, or center.
  1753. -outlinestipplebitmap
  1754. Stipple pattern used to draw the item’s outline in its normal state.
  1755. -activeoutlinestipplebitmap
  1756. Stipple pattern used to draw the item’s outline in its active state.
  1757. -disabledoutlinestipplebitmap
  1758. Stipple pattern used to draw the item’s outline in its disabled state.
  1759. -stipplebitmap
  1760. Stipple pattern used to fill the the item in its normal state.
  1761. -activestipplebitmap
  1762. Stipple pattern used to fill the the item in its active state.
  1763. -disabledstipplebitmap
  1764. Stipple pattern used to fill the the item in its disabled state.
  1765. 39
  1766. Tcl/Tk Reference Guide
  1767. -statestate
  1768. Override the canvas widget’s global state option.
  1769. -tagstagList
  1770. Replace any existing tags with tagList which may be empty.
  1771. -widthoutlineWidth
  1772. Width of the outline drawn around the item’s region in its normal state.
  1773. -activewidthoutlineWidth
  1774. Width of the outline drawn around the item’s region in its active state.
  1775. -disabledwidthoutlineWidth
  1776. Width of the outline drawn around the item’s region in its disabled state.
  1777. Canvas Item Types
  1778. canvas create arc x1 y1 x2 y2 [option value . . . ]
  1779. canvas create arc coordList [option value . . . ]
  1780. -activedashpattern -disabledoutlinecolor
  1781. -activefillcolor -disabledstipplebitmap
  1782. -activeoutlinestipplebitmap -disabledwidthoutlineWidth
  1783. -activeoutlinecolor -fill color
  1784. -activestipplebitmap -offsetoffset
  1785. -activewidthoutlineWidth -outlinestipplebitmap
  1786. -dashoffsetoffset -outlinecolor
  1787. -dashpattern -statestate
  1788. -disableddashpattern -stipplebitmap
  1789. -disabledfillcolor -tags tagList
  1790. -disabledoutlinestipplebitmap -widthoutlineWidth
  1791. -extentdegrees
  1792. Size of the angular range occupied by arc measured counter-clockwise from
  1793. the start.
  1794. -startdegrees
  1795. Starting angle measured from 3-o’clock position.
  1796. -style pieslice|chord|arc
  1797. How to “complete” the region of the arc.
  1798. canvas create bitmap x y [option value . . . ]
  1799. canvas create bitmap coordList [option value . . . ]
  1800. -statestate -tags tagslist
  1801. -anchoranchorPos
  1802. How to position the bitmap relative to the positioning point for the item: n,
  1803. ne, e, se, s, sw, w, nw, or center(default).
  1804. -backgroundcolor
  1805. Color to use for the bitmap’s ’0’ valued pixels in its normal state.
  1806. -activebackgroundbitmap
  1807. Color to use for the bitmap’s ’0’ valued pixels in its active state.
  1808. -disabledbackgroundbitmap
  1809. Color to use for the bitmap’s ’0’ valued pixels in its disabled state.
  1810. -bitmapbitmap
  1811. Bitmap to display in the item in its normal state.
  1812. -activebitmapbitmap
  1813. Bitmap to display in the item in its active state.
  1814. 40
  1815. Tcl/Tk Reference Guide
  1816. -disabledbitmapbitmap
  1817. Bitmap to display in the item in its disabled state.
  1818. -foregroundcolor
  1819. Color to use for the bitmap’s ’1’ valued pixels in its normal state.
  1820. -activeforegroundbitmap
  1821. Color to use for the bitmap’s ’1’ valued pixels in its active state.
  1822. -disabledforegroundbitmap
  1823. Color to use for the bitmap’s ’1’ valued pixels in its disabled state.
  1824. canvas create image x y [option value . . . ]
  1825. canvas create image coordList [option value . . . ]
  1826. -statestate -tags tagslist
  1827. -anchoranchorPos
  1828. How to position the image relative to the positioning point for the item: n,
  1829. ne, e, se, s, sw, w, nw, or center(default).
  1830. -imagename
  1831. Name of the image to display in its normal state.
  1832. -activeimagename
  1833. Name of the image to display in its active state.
  1834. -disabledimagename
  1835. Name of the image to display in its disabled state.
  1836. canvas create line x1 y1 . . . xN yN [option value . . . ]
  1837. canvas create line coordList [option value . . . ]
  1838. -activedashpattern -disabledstipplebitmap
  1839. -activefillcolor -disabledwidthoutlineWidth
  1840. -activestipplebitmap -fill color
  1841. -activewidthoutlineWidth -statestate
  1842. -dashoffsetoffset -stipplebitmap
  1843. -dashpattern -tags tagList
  1844. -disableddashpattern -widthoutlineWidth
  1845. -disabledfillcolor
  1846. -arrow none|first|last|both
  1847. Specify on which ends of the line to draw arrows.
  1848. -arrowshapeshape
  1849. Three element list which describes shape of arrow.
  1850. -capstyle butt|projecting|round
  1851. How to draw caps at endpoints of the line. One of butt (default),
  1852. projectingor round.
  1853. -joinstyle bevel|miter|round
  1854. How joints are to be drawn at vertices. One of bevel, miter (default), or
  1855. round.
  1856. -smoothsmoothMethod
  1857. Should the line be drawn as a set of parabolic splines (true or false), or
  1858. as smoothMethod? The only built-in method is bezier.
  1859. -splinestepsnumber
  1860. Degree of smoothness desired for curves.
  1861. canvas create oval x1 y1 x2 y2 [option value . . . ]
  1862. canvas create oval coordList [option value . . . ]
  1863. -activedashpattern -disabledoutlinecolor
  1864. 41
  1865. Tcl/Tk Reference Guide
  1866. -activefillcolor -disabledstipplebitmap
  1867. -activeoutlinestipplebitmap -disabledwidthoutlineWidth
  1868. -activeoutlinecolor -fill color
  1869. -activestipplebitmap -offsetoffset
  1870. -activewidthoutlineWidth -outlinestipplebitmap
  1871. -dashoffsetoffset -outlinecolor
  1872. -dashpattern -statestate
  1873. -disableddashpattern -stipplebitmap
  1874. -disabledfillcolor -tags tagList
  1875. -disabledoutlinestipplebitmap -widthoutlineWidth
  1876. canvas create polygon x1 y1 . . . xN yN [option value . . . ]
  1877. canvas create polygon coordList [option value . . . ]
  1878. -activedashpattern -disabledoutlinecolor
  1879. -activefillcolor -disabledstipplebitmap
  1880. -activeoutlinestipplebitmap -disabledwidthoutlineWidth
  1881. -activeoutlinecolor -fill color
  1882. -activestipplebitmap -offsetoffset
  1883. -activewidthoutlineWidth -outlinestipplebitmap
  1884. -dashoffsetoffset -outlinecolor
  1885. -dashpattern -statestate
  1886. -disableddashpattern -stipplebitmap
  1887. -disabledfillcolor -tags tagList
  1888. -disabledoutlinestipplebitmap -widthoutlineWidth
  1889. -joinstylestyle
  1890. How joints are to be drawn at vertices. One of bevel, miter (default), or
  1891. round.
  1892. -smoothboolean
  1893. Should the polygon be drawn as a set of parabolic splines.
  1894. -splinestepsnumber
  1895. Degree of smoothness desired for curved perimeter.
  1896. canvas create rectangle x1 y1 x2 y2 [option value . . . ]
  1897. canvas create rectangle coordList [option value . . . ]
  1898. -activedashpattern -disabledoutlinecolor
  1899. -activefillcolor -disabledstipplebitmap
  1900. -activeoutlinestipplebitmap -disabledwidthoutlineWidth
  1901. -activeoutlinecolor -fill color
  1902. -activestipplebitmap -offsetoffset
  1903. -activewidthoutlineWidth -outlinestipplebitmap
  1904. -dashoffsetoffset -outlinecolor
  1905. -dashpattern -statestate
  1906. -disableddashpattern -stipplebitmap
  1907. -disabledfillcolor -tags tagList
  1908. -disabledoutlinestipplebitmap -widthoutlineWidth
  1909. canvas create text x y [option value . . . ]
  1910. canvas create text coordList [option value . . . ]
  1911. -activefillcolor -fill color
  1912. -activestipplebitmap -statestate
  1913. -disabledfillcolor -stipplebitmap
  1914. -disabledstipplebitmap -tags tagList
  1915. 42
  1916. Tcl/Tk Reference Guide
  1917. -anchoranchorPos
  1918. How to position the text relative to the positioning point for the item: n, ne,
  1919. e, se, s, sw, w, nw, or center(default).
  1920. -fontfontName
  1921. Font to use for the text item.
  1922. -justify left|right|center
  1923. How to justify text within its bounding region. One of left (default),
  1924. right or center.
  1925. -textstring
  1926. Characters to be displayed in the text item.
  1927. -widthlineLength
  1928. Maximum line length for the text. If zero, break only on \n.
  1929. canvas create window x y [option value . . . ]
  1930. canvas create window coordList [option value . . . ]
  1931. -statestate -tags tagList
  1932. -anchoranchorPos How to position the text relative to the positioning point
  1933. for the item: n, ne, e, se, s, sw, w, nw, or center
  1934. (default).
  1935. -heightheight Height in screen units to assign item’s window.
  1936. -widthwidth Width in screen units to assign item’s window.
  1937. -windowpathName Window to associate with item.
  1938. Canvas Postscript Options
  1939. -channelchannelId
  1940. Specifies the name of an opened channel in which to write the Postscript. If
  1941. not specified, the Postscript is returned as the result of the command.
  1942. -colormapvarName
  1943. Specifies a color mapping to use where varName is an array variable whose
  1944. elements specify Postscript code to set a particular color value.
  1945. -colormode color|grey|mono
  1946. Specifies how to output color information.
  1947. -filefileName
  1948. Specifies the name of the file in which to write the Postscript. If not
  1949. specified, the Postscript is returned as the result of the command.
  1950. -fontmapvarName
  1951. Specifies a font mapping to use where varName is an array variable whose
  1952. elements specify the Postscript font and size to use as a two element list.
  1953. -heightsize
  1954. Specifies the height of the area of the canvas to print. Defaults to the height
  1955. of the canvas window
  1956. -pageanchoranchor
  1957. Specifies which point of the printed area should be appear over the
  1958. positioning point on the page. Defaults to center.
  1959. -pageheightsize
  1960. Specifies that the Postscript should be scaled in both x and y so that the
  1961. printed area is size high on the Postscript page.
  1962. -pagewidthsize
  1963. Specifies that the Postscript should be scaled in both x and y so that the
  1964. printed area is size wide on the Postscript page.
  1965. 43
  1966. Tcl/Tk Reference Guide
  1967. -pagexposition
  1968. Set the x-coordinate of the positioning point on the page to position.
  1969. -pageyposition
  1970. Set the y-coordinate of the positioning point on the page to position.
  1971. -rotateboolean
  1972. Whether the printed area is to be rotated 90 degrees. (“landscape”).
  1973. -widthsize
  1974. Specifies the width of the area of the canvas to print. Defaults to the width of
  1975. the canvas window
  1976. -x position
  1977. Set the x-coordinate of the left edge of canvas area to print.
  1978. -y position
  1979. Set the y-coordinate of the top edge of canvas area to print.
  1980. Tkspline 0.4 Package
  1981.  
  1982. An additional smoothing method for canvas line and polygon items. Package
  1983. command is:
  1984. package require Tkspline
  1985. canvas create line . . . -smooth spline. . .
  1986. canvas create polygon . . . -smooth spline. . .
  1987. Spline smoothing requires 3n + 1 points, where n is the number of spline
  1988. segments.
  1989. The curves generated with the standard -smooth trueoption have the following
  1990. properties:
  1991. • the curve is always tangential to a straight line between consecutive points.
  1992. • the curve is only guaranteed to intersect the first and last points of lines.
  1993. • the curve is not guaranteed to intersect any points of polygons.
  1994. With -smooth splinethe curves generated have the following different
  1995. properties:
  1996. • the curve is guaranteed to intersect the first point, and every third point after
  1997. that.
  1998. • each segment of the curve shares endpoints with the adjacent segments, but
  1999. is otherwise independant of them.
  2000. • the curve is guaranteed to be tangential to a line between n and n + 1 at
  2001. point n, and also to a line between n + 2 and n + 3 at point n + 3.
  2002. • the curve is not guaranteed to be smooth at the junctions between segments
  2003. unless the shared point and the points either side of it are on a straight line.
  2004. 25. The Entry Widget
  2005. Entry Widget Options
  2006. -background -highlightcolor -relief
  2007. -borderwidth -highlightthickness -selectbackground
  2008. -cursor -insertbackground -selectborderwidth
  2009. -disabledbackground -insertborderwidth -selectforeground
  2010. 44
  2011. Tcl/Tk Reference Guide
  2012. -disabledforeground -insertofftime -state
  2013. -exportselection -insertontime -takefocus
  2014. -font -insertwidth -textvariable
  2015. -foreground -justify -width
  2016. -highlightbackground -readonlybackground -xscrollcommand
  2017. -invalidcommandtclCommand
  2018. Script to evaluate when validateCommand returns false. (Abbrev:
  2019. -invcmd).
  2020. -showchar
  2021. Show char rather than actual characters for each character in entry.
  2022. -validatemode
  2023. Mode in which validation should operate: none (default), focus,
  2024. focusin, focusout, key, or all. See Validation above.
  2025. -validatecommandtclCommand
  2026. Evaluate tclCommand, which must return a boolean, to validate the input
  2027. into the entry widget. If it returns false then the addition is rejected and will
  2028. not occur, and the invalidCommand will be evaluated. (Abbrev: -vcmd).
  2029. Entry Indices: number, anchor, end, insert, sel.first,
  2030. sel.last,@x-coord
  2031. Entry Widget Commands
  2032. entry bbox index
  2033. Returns bounding box of character given by index.
  2034. entry delete first [last]
  2035. Delete characters from first through character just before last.
  2036. entry get
  2037. Returns the entry’s string.
  2038. entry icursor index
  2039. Display insertion cursor just before character at index.
  2040. entry index index
  2041. Returns the numerical index corresponding to index.
  2042. entry insert index string
  2043. Insert string just before character at index.
  2044. entry scan option args
  2045. See Widget Scroll Commands above.
  2046. entry selection adjust index
  2047. Adjust nearest end of current selection to be at index and set the other end to
  2048. the anchor point.
  2049. entry selection clear
  2050. Clear the selection if currently in the widget.
  2051. entry selection from index
  2052. Set the anchor point to be at index.
  2053. entry selection present
  2054. Returns 1 is any characters are selected, 0 otherwise.
  2055. entry selection range start end
  2056. Select the characters from start through character just before end.
  2057. entry selection to index
  2058. Set the selection to extend between index and anchor point.
  2059. 45
  2060. Tcl/Tk Reference Guide
  2061. entry validate
  2062. Force an evaluation of validateCommand.
  2063. entry xview args
  2064. See Widget Scroll Commands above.
  2065. 26. The Listbox Widget
  2066. Listbox Widget Options
  2067. -activestyle -height -selectforeground
  2068. -background -highlightbackground -setgrid
  2069. -borderwidth -highlightcolor -state
  2070. -cursor -highlightthickness -takefocus
  2071. -disabledforeground -relief -width
  2072. -exportselection -selectbackground -xscrollcommand
  2073. -font -selectborderwidth -yscrollcommand
  2074. -foreground
  2075. -listvariable Name of a variable, the value of which is a list to be
  2076. displayed inside the widget.
  2077. -selectmodemode One of single, browse(default), multipleor
  2078. extended
  2079. Listbox Indices: number (starts at 0), active, anchor, end, @x,y
  2080. Listbox Item Options
  2081. -background -selectbackground -selectforeground
  2082. -foreground
  2083. Listbox Widget Commands
  2084. listbox activate index
  2085. Sets the active element to index.
  2086. listbox bbox index
  2087. Returns a list {x y width height} bounding element at index.
  2088. listbox curselection
  2089. Returns list of indices of all elements currently selected.
  2090. listbox delete index1 [index2]
  2091. Delete range of elements from index1 to index2 (defaults to index1).
  2092. listbox get index1 [index2]
  2093. Return as a list contents of elements from index1 to index2.
  2094. listbox index index
  2095. Returns position index in number notation.
  2096. listbox insert index [element . . . ]
  2097. Insert specified elements just before element at index.
  2098. listbox itemcget index option
  2099. Returns the value option for the item given by index.
  2100. listbox itemconfigure index [option value] . . .
  2101. Query or Modify item-specific options for the items given by option.
  2102. listbox nearest y
  2103. Return index of element nearest to y-coordinate.
  2104. 46
  2105. Tcl/Tk Reference Guide
  2106. listbox scan args
  2107. See Widget Scroll Commands above.
  2108. listbox see index
  2109. Adjust the view in window so element at index is completely visible.
  2110. listbox selection anchor index
  2111. Set the selection anchor to element at index.
  2112. listbox selection clear first [last]
  2113. De-select elements between first and last inclusive.
  2114. listbox selection includes index
  2115. Returns 1 if element at index is selected, 0 otherwise.
  2116. listbox selection set first [last]
  2117. Add all elements between first and last inclusive to selection.
  2118. listbox size
  2119. Returns number of elements in listbox.
  2120. listbox xview|yview args
  2121. See Widget Scroll Commands above.
  2122. 27. The Menu Widget
  2123. Menu Widget Options
  2124. -activebackground -borderwidth -foreground
  2125. -activeborderwidth -cursor -relief
  2126. -activeforeground -disabledforeground -takefocus
  2127. -background -font
  2128. -postcommandtclCommand
  2129. Specify Tcl command to invoke immediately before the menu is posted.
  2130. -selectcolorcolor
  2131. Specifies indicator color for checkbutton and radiobutton entries.
  2132. -tearoffboolean
  2133. Whether to include a tear-off entry at top of menu.
  2134. -tearoffcommandtclCmd
  2135. Specifies command to be run when menu is torn off. The name of the menu
  2136. and the new torn-off window will be appended on invocation.
  2137. -titlestring
  2138. Uses string for title of window used when the menu is torn off.
  2139. -typetype
  2140. Used at creation where type is one of menubar, tearoff, or normal.
  2141. Entry Types: cascade, checkbutton, command, radiobutton,
  2142. separator
  2143. Menu Indices: number, end, active, last, none, @y-coord,
  2144. matchPattern
  2145. Menu Widget Commands
  2146. menu activate index
  2147. Change state of entry at index to be sole active entry in menu.
  2148. menu add type [option value . . . ]
  2149. Add new entry of type type to bottom of menu. See below for options.
  2150. 47
  2151. Tcl/Tk Reference Guide
  2152. menu clone newMenuName [cloneType]
  2153. Clones menu as a new menu newMenuName of type cloneType (see -type).
  2154. menu delete index1 [index2]
  2155. Delete all entries between index1 and index2 inclusive.
  2156. menu entrycget index option
  2157. Return current value of option for entry at index.
  2158. menu entryconfigure index [option value . . . ]
  2159. Set option values for entry at index.
  2160. menu index index
  2161. Returns the numerical index corresponding to index.
  2162. menu insert index type [option value . . . ]
  2163. Same as add but inserts new entry just before entry at index.
  2164. menu invoke index
  2165. Invoke the action of the menu entry at index.
  2166. menu post x y
  2167. Display menu on screen at root-window coordinates given by x y.
  2168. menu postcascade index
  2169. Post sub-menu associated with cascade entry at index.
  2170. menu type index
  2171. Returns type of menu entry at index.
  2172. menu unpost
  2173. Unmap window so it is no longer displayed.
  2174. menu yposition index
  2175. Returns the y-coordinate within the menu window of the topmost pixel in
  2176. the entry specified by index.
  2177. Menu Entry Options
  2178. The following options work for all cascade, checkbutton, command, and
  2179. radiobutton entries unless otherwise specified.
  2180. -activebackground -bitmap -image
  2181. -activeforeground -font -state
  2182. -background -foreground -underline
  2183. -acceleratorstring
  2184. Specifies string to display at right side of menu entry.
  2185. -columnbreakvalue
  2186. When value is 1, entry appears at top of a new column in menu.
  2187. -commandtclCommand
  2188. TCL command to evaluate when entry is invoked.
  2189. -compoundhow
  2190. Should both image and text be displayed, and if so, how the image is placed
  2191. relative to the text. The value how is one of bottom, center, left,
  2192. none (default), right or top.
  2193. -hidemarginvalue
  2194. When value is 1, the standard margins are not drawn around entry.
  2195. -indicatoronboolean
  2196. Whether indictor for checkbutton or radiobutton entry should be displayed.
  2197. -labelstring
  2198. Textual string to display on left side of menu entry.
  2199. 48
  2200. Tcl/Tk Reference Guide
  2201. -menupathName
  2202. Pathname to a menu to post when cascade entry is active.
  2203. -offvaluevalue
  2204. Value to store in checkbutton entry’s associated variable when de-selected.
  2205. -onvaluevalue
  2206. Value to store in checkbutton entry’s associated variable when selected.
  2207. -selectcolorcolor
  2208. Color for indicator in checkbutton and radiobutton entries.
  2209. -selectimageimage
  2210. Image to draw in indicator for checkbutton and radiobutton entries.
  2211. -valuevalue
  2212. Value to store in radiobutton entry’s associated variable when selected.
  2213. -variablevariable
  2214. Name of global variable to set when checkbutton or radiobutton is selected.
  2215. 28. The Text Widget
  2216. Text Widget Options
  2217. -background -highlightthickness -selectbackground
  2218. -borderwidth -insertbackground -selectborderwidth
  2219. -cursor -insertborderwidth -selectforeground
  2220. -exportselection -insertofftime -setgrid
  2221. -font -insertontime -state
  2222. -foreground -insertwidth -takefocus
  2223. -height -padx -width
  2224. -highlightbackground -pady -xscrollcommand
  2225. -highlightcolor -relief -yscrollcommand
  2226. -autoseparatorsboolean Should separators be automatically inserted in the
  2227. undo stack.
  2228. -maxundointeger Maximum compound undo actions.
  2229. -spacing1size Space in screen units above paragraphs.
  2230. -spacing2size Space in screen units between paragraph lines.
  2231. -spacing3size Space in screen units below paragraphs.
  2232. -tabstabList
  2233. Set of tab stops as a list of screen distances giving their positions. Each stop
  2234. may be followed by one of left, right, center, or numeric.
  2235. -undoboolean Should undo mechanism be enabled.
  2236. -wrap none|char|word How to wrap lines.
  2237. Text Indices
  2238. Syntax: base [modifier . . . ]
  2239. Base: line.char, @x,y, end, mark, tag.first, tag.last, pathName
  2240. (embedded window), imageName (embedded image)
  2241. Modifier: ± count chars, ± count lines, linestart, lineend,
  2242. wordstart, wordend
  2243. Ranges: Ranges include all characters from the start index up to but not
  2244. including the character at the stop index.
  2245. 49
  2246. Tcl/Tk Reference Guide
  2247. Text Tag Options
  2248. -background -justify -spacing2
  2249. -borderwidth -relief -spacing3
  2250. -font -spacing1 -wrap
  2251. -foreground
  2252. -bgstipplebitmap Stipple pattern for background.
  2253. -elideboolean Whether the data should be elided (not displayed and
  2254. takes no space.)
  2255. -fgstipplebitmap Stipple pattern for foreground.
  2256. -lmargin1size Left margin of first line of a paragraph.
  2257. -lmargin2size Left margin of wrapped lines of a paragraph.
  2258. -offsetsize Offset of baseline from normal baseline.
  2259. -overstrikeboolean Whether to overstrike text.
  2260. -rmarginsize Right margin of all lines.
  2261. -tabstabList Set of tab stops (see -tabsabove).
  2262. -underlineboolean Whether to underline text.
  2263. Text Embedded Window Options
  2264. -align top|center|bottom|baseline
  2265. How window is vertically aligned with its line.
  2266. -createtclCommand
  2267. Script to create and return window pathname if no -windowoption is
  2268. given.
  2269. -padxwidth
  2270. Extra space in screen units to leave on the left and right side of window.
  2271. -padyheight
  2272. Extra space in screen units to leave on the top and bottom of window.
  2273. -stretchboolean
  2274. Whether window should be stretched vertically to fill line.
  2275. -windowpathName
  2276. Name of window to display.
  2277. Text Embedded Image Options
  2278. -align top|center|bottom|baseline
  2279. Where image is displayed on the line.
  2280. -imageimage
  2281. Specifies Tk image to use for embedded image.
  2282. -nameimageName
  2283. Specifies name which may be used to reference the embedded image.
  2284. -padxwidth
  2285. Extra space in screen units to leave on the left and right side of image.
  2286. -padyheight
  2287. Extra space in screen units to leave on the top and bottom of image.
  2288. 50
  2289. Tcl/Tk Reference Guide
  2290. Text Widget Commands
  2291. text bbox index
  2292. Returns a list {x y width height} bounding character at index.
  2293. text compare index1 op index2
  2294. Compares indices index1 and index2 according to relational operator op.
  2295. text debug boolean
  2296. Turn on/off debugging and internal consistency checks in the B-tree code
  2297. associated with text widgets.
  2298. text delete index1 [index2 . . . ]
  2299. Delete range of given text range.
  2300. text dlineinfo index
  2301. Returns a list {x y width height baseline} describing the screen area taken by
  2302. display line at index.
  2303. text dump [switches] index1 [index2]
  2304. Returns detailed info on text widget contents in given text range. Switches
  2305. include -all, -image, -mark, -tag, -text, -windowfor specifying
  2306. type of info returned. The switch -commandcommand exists to invoke a
  2307. procedure on each element type in the range.
  2308. text edit modified [boolean]
  2309. Query or set the modified flag.
  2310. text edit redo
  2311. Reapply last undone edits provided no other edits were done since then.
  2312. text edit reset
  2313. Clears the undo and redo stacks.
  2314. text edit separator
  2315. Inserts a separator (boundary) on the undo stack.
  2316. text edit undo
  2317. Undoes the last edit action. An edit action is defined as all the insert and
  2318. delete commands that are recorded on the undo stack between two
  2319. separators.
  2320. text get index1 [index2 . . . ]
  2321. Returns characters in given range. With multiple indices, a list is returned.
  2322. text image cget index option
  2323. Return current value of option for embedded image at index.
  2324. text image configure index [option [value [option value . . . ]]]
  2325. Modifies embedded image-specific options for the image at index.
  2326. text image create index [option value . . . ]
  2327. Create a new embedded image at position index with specified options.
  2328. text image names
  2329. Returns list of names of all images embedded in text widget.
  2330. text index index
  2331. Returns position index in line.char notation.
  2332. text insert index [string [tagList string tagList . . . ]]
  2333. Insert string into text at index applying tags from tagList.
  2334. text mark gravity markName [left|right]
  2335. Returns (or sets) which adjacent character a mark is attached to.
  2336. text mark names
  2337. Returns a list of the names of all marks currently set.
  2338. 51
  2339. Tcl/Tk Reference Guide
  2340. text mark next | previous index
  2341. Return name of next/previous mark at or after/before index.
  2342. text mark set markName index
  2343. Set mark markName to position just before character at index.
  2344. text mark unset markName [markName . . . ]
  2345. Remove each mark specified so they are no longer usable as indices.
  2346. text scan args
  2347. See Widget Scroll Commands above.
  2348. text search [switches] pattern index [stopIndex]
  2349. Returns index of first character matching pattern in text range index to
  2350. stopIndex. Switches: -forwards, -backwards, -exact, -regexp,
  2351. -countvar, -nocase, -elide
  2352. text see index
  2353. Adjust the view in window so character at index is completely visible.
  2354. text tag add tagName index1 [index2 . . . ]
  2355. Apply tag tagName to characters in given range.
  2356. text tag bind tagName [sequence [tclCommand]]
  2357. Arrange for tclCommand to be run whenever event sequence occurs for a
  2358. character with tag tagName.
  2359. text tag cget tagName option
  2360. Return current value of option for tag tagName.
  2361. text tag configure tagName [option [value [option value . . . ]]]
  2362. Modifies tag-specific options for the tag tagName.
  2363. text tag delete tagName [tagName . . . ]
  2364. Delete all tag information for given tags.
  2365. text tag lower tagName [belowThis]
  2366. Change priority of tag tagName so it is just below tag belowThis.
  2367. text tag names [index]
  2368. Returns a list of the names of all tags associated with character at index. If
  2369. index is not given, returns list of all tags defined in widget.
  2370. text tag nextrange tagName index1 [index2]
  2371. Searches character range index1 to index2 (default end) for the first region
  2372. tagged with tagName. Returns character range of region found.
  2373. text tag prevrange tagName index1 [index2]
  2374. Like nextrange but searches backwards from index1 to index2 (default 1.0).
  2375. text tag raise tagName [aboveThis]
  2376. Change priority of tag tagName so it is just above tag aboveThis.
  2377. text tag ranges tagName
  2378. Returns a list describing all character ranges tagged with tagName.
  2379. text tag remove tagName index1 [index2 . . . ]
  2380. Remove tag tagName for all characters in range index1 to index2.
  2381. text window cget index option
  2382. Return current value of option for embedded window at index.
  2383. text window configure index [option [value [option value . . . ]]]
  2384. Modifies embedded window-specific options for the window at index.
  2385. text window create index [option value . . . ]
  2386. Create a new embedded window at position index with specified options.
  2387. text window names
  2388. Returns list of names of all windows embedded in text widget.
  2389. 52
  2390. Tcl/Tk Reference Guide
  2391. text xview|yview args
  2392. See Widget Scroll Commands above.
  2393. 29. Other Standard Widgets
  2394. Button
  2395. -activebackground -foreground -repeatdelay
  2396. -activeforeground -height -repeatinterval
  2397. -anchor -highlightbackground -state
  2398. -background -highlightcolor -takefocus
  2399. -bitmap -highlightthickness -text
  2400. -borderwidth -image -textvariable
  2401. -command -justify -underline
  2402. -cursor -padx -width
  2403. -disabledforeground -pady -wraplength
  2404. -font -relief
  2405. -compoundoption
  2406. Should the button display both an image and text, and if so, where the image
  2407. should be placed relative to the text. Valid options are bottom, center,
  2408. left, none (default), right and top.
  2409. -defaultstate
  2410. Set state of default ring, one of active, normal, or disabled.
  2411. -overrelief flat|groove|raised|ridge|sunken
  2412. Alternative relief for the button when the mouse cursor is over the widget.
  2413. button flash
  2414. Alternate checkbutton between active and normal colors.
  2415. button invoke
  2416. Toggle the selection state of the checkbutton and invoke the Tcl command
  2417. specified with -command(if present.)
  2418. Checkbutton
  2419. -activebackground -font -pady
  2420. -activeforeground -foreground -relief
  2421. -anchor -height -state
  2422. -background -highlightbackground -takefocus
  2423. -bitmap -highlightcolor -text
  2424. -borderwidth -highlightthickness -textvariable
  2425. -command -image -underline
  2426. -cursor -justify -width
  2427. -disabledforeground -padx -wraplength
  2428. -indicatoronboolean
  2429. Whether or not the indicator should be drawn.
  2430. -offrelief flat|raised
  2431. The relief (default raised) when the indicator is not drawn and the
  2432. checkbutton is off.
  2433. -offvaluevalue
  2434. Value given to variable specified with -variableoption when the
  2435. checkbutton is de-selected.
  2436. 53
  2437. Tcl/Tk Reference Guide
  2438. -onvaluevalue
  2439. Value given to variable specified with -variableoption when the
  2440. checkbutton is selected.
  2441. -overrelief flat|groove|raised|ridge|sunken
  2442. Alternative relief for the checkbutton when the mouse cursor is over the
  2443. widget.
  2444. -selectcolorcolor
  2445. Color used to fill in indicator when selected.
  2446. -selectimageimage
  2447. Image displayed in indicator when selected.
  2448. -variablevariable
  2449. Variable to associate with checkbutton.
  2450. checkbutton deselect
  2451. Deselect the checkbutton.
  2452. checkbutton flash
  2453. Alternate checkbutton between active and normal colors.
  2454. checkbutton invoke
  2455. Toggle the selection state of the checkbutton and invoke the Tcl command
  2456. specified with -command(if present.)
  2457. checkbutton select
  2458. Select the checkbutton.
  2459. checkbutton toggle
  2460. Toggle the selection state of the checkbutton.
  2461. Frame
  2462. -borderwidth -highlightcolor -relief
  2463. -cursor -highlightthickness -takefocus
  2464. -height -padx -width
  2465. -highlightbackground -pady
  2466. -backgroundcolor
  2467. Same as standard -backgroundoption except it may be the empty string
  2468. to preserve colormap.
  2469. -classname
  2470. Class name to use in querying the option database and for bindings.
  2471. -colormapcolormap
  2472. Color map to use for window. May be the word new or pathname of another
  2473. window.
  2474. -containerboolean
  2475. Whether the frame will be a container to embed another application.
  2476. -visualvisual
  2477. Visual to use for the window if different from parent.
  2478. Label
  2479. -activebackground -foreground -pady
  2480. -activeforeground -height -relief
  2481. -anchor -highlightbackground -takefocus
  2482. -background -highlightcolor -text
  2483. -bitmap -highlightthickness -textvariable
  2484. 54
  2485. Tcl/Tk Reference Guide
  2486. -borderwidth -image -underline
  2487. -cursor -justify -width
  2488. -disabledforeground -padx -wraplength
  2489. -font
  2490. -compoundwhere
  2491. Should the label display both an image and text, and where the image should
  2492. be placed relative to the text: one of bottom, center, left, none
  2493. (default), right or top.
  2494. Labelframe
  2495. -borderwidth -highlightbackground -relief
  2496. -cursor -highlightcolor -takefocus
  2497. -font -highlightthickness -text
  2498. -foreground -padx -width
  2499. -height -pady
  2500. -backgroundcolor
  2501. Same as standard -backgroundoption except color may be the empty
  2502. string to preserve colormap.
  2503. -classname
  2504. Class name to use in querying the option database and for bindings.
  2505. -colormapcolormap
  2506. Color map to use for window. May be the word new or pathname of another
  2507. window.
  2508. -containerboolean
  2509. Whether the labelframe will be a container to embed another application.
  2510. -labelanchoranchorPos
  2511. Where to place the label. Valid anchorPos values are n, ne, en, e, es, se,
  2512. s, sw, ws, w, wn, and nw (default).
  2513. -labelwidgetwindow
  2514. Widget to use as label.
  2515. -visualvisual
  2516. Visual to use for the window if different from parent.
  2517. Menubutton
  2518. -activebackground -foreground -relief
  2519. -activeforeground -height -state
  2520. -anchor -highlightbackground -takefocus
  2521. -background -highlightcolor -text
  2522. -bitmap -highlightthickness -textvariable
  2523. -borderwidth -image -underline
  2524. -cursor -justify -width
  2525. -disabledforeground -padx -wraplength
  2526. -font -pady
  2527. -compoundwhere
  2528. Should the menubutton display both an image and text, and where the image
  2529. 55
  2530. Tcl/Tk Reference Guide
  2531. should be placed relative to the text: one of bottom, center, left,
  2532. none (default), right or top.
  2533. -directiondirection
  2534. Where to pop up menu where direction is one of above, below, left,
  2535. right and flush.
  2536. -indicatoronboolean
  2537. If true then a small indicator will be displayed on the button’s right side and
  2538. the default menu bindings will treat this as an option menubutton.
  2539. -menupathName
  2540. Pathname of menu widget to post when button is invoked.
  2541. Message
  2542. -anchor -highlightbackground -relief
  2543. -background -highlightcolor -takefocus
  2544. -borderwidth -highlightthickness -text
  2545. -cursor -justify -textvariable
  2546. -font -padx -width
  2547. -foreground -pady
  2548. -aspectinteger
  2549. Ratio of text width to text height times 100 to use to display text.
  2550. Panedwindow
  2551. -background -height -relief
  2552. -borderwidth -orient -width
  2553. -cursor
  2554. -handlepadoffset
  2555. Offset (pixels) from top or left of sash to draw handle.
  2556. -handlesizelength
  2557. Side length (pixels) of a sash handle.
  2558. -opaqueresizeboolean
  2559. Whether panes should be resized as a sash is moved (true), or deferred until
  2560. the sash is placed (false).
  2561. -sashcursorcursor
  2562. Cursor to display when over a sash.
  2563. -sashpadpadding
  2564. Amount of padding (pixels) to leave on each side of a sash.
  2565. -sashrelief flat|groove|raised|ridge|sunken
  2566. Relief to use when drawing a sash.
  2567. -sashwidthwidth
  2568. Width (pixels) of each sash.
  2569. -showhandleboolean
  2570. Should sash handles be shown.
  2571. panedwindow add window . . . [option value . . . ]
  2572. Add window . . . to panedwindow, each in a separate pane. The
  2573. Panedwindow Management option value pairs are described below.
  2574. panedwindow forget window . . .
  2575. Remove pane containing window from the panedwindow.
  2576. 56
  2577. Tcl/Tk Reference Guide
  2578. panedwindow identify x y
  2579. Identify the panedwindow component underneath the window coordinates x
  2580. y. If over a sash or sash handle, return {index sash|handle}, otherwise
  2581. return an empty list.
  2582. panedwindow proxy coord
  2583. Return list containing x y coordinates of most recent sash proxy (used for
  2584. rubberband-style pane resizing) location.
  2585. panedwindow proxy forget
  2586. Remove proxy (used for rubberband-style pane resizing) from display.
  2587. panedwindow proxy place x y
  2588. Place proxy (used for rubberband-style pane resizing) at coordinates x y.
  2589. panedwindow sash coord index
  2590. Return current x y coordinates of top-left corner of region containing sash
  2591. given by index (an integer from 0 to 1 less than the number of panes in
  2592. panedwindow).
  2593. panedwindow sash dragto index x y
  2594. Move sash at index by difference between x y and coordinates given to last
  2595. sash mark command.
  2596. panedwindow sash mark index x y
  2597. Records x y coordinates for sash at index.
  2598. panedwindow sash place index x y
  2599. Move sash at index to coordinates x y.
  2600. panedwindow panecget window option
  2601. Query Panedwindow Management option (described below).
  2602. panedwindow paneconfigure window [option [value [option value . . . ]]]
  2603. Query or modify Panedwindow Management option (described below) for
  2604. window.
  2605. panedwindow panes
  2606. Return ordered list of widgets managed by panedwindow.
  2607. Panedwindow Management Options
  2608. -afterwindow
  2609. Insert new window after window.
  2610. -beforewindow
  2611. Insert new window before window.
  2612. -heightsize
  2613. Specify height (pixels) for window. The size may be an empty string.
  2614. -minsizen
  2615. Size of window cannot be made less than n (pixels).
  2616. -padxn
  2617. Extra space (pixels) to leave on each side of window.
  2618. -padyn
  2619. Extra space (pixels) to leave on top and bottom of window.
  2620. -stickystyle
  2621. For windows smaller than the containing pane, position or stretch the
  2622. window based on style (string containing zero or more of the characters
  2623. [nsew]).
  2624. -widthsize
  2625. Specify width (pixels) for window. The size may be an empty string.
  2626. 57
  2627. Tcl/Tk Reference Guide
  2628. Radiobutton
  2629. -activebackground -font -pady
  2630. -activeforeground -foreground -relief
  2631. -anchor -height -state
  2632. -background -highlightbackground -takefocus
  2633. -bitmap -highlightcolor -text
  2634. -borderwidth -highlightthickness -textvariable
  2635. -command -image -underline
  2636. -cursor -justify -width
  2637. -disabledforeground -padx -wraplength
  2638. -indicatoronboolean
  2639. Whether or not the indicator should be drawn.
  2640. -offrelief flat|raised
  2641. The relief (default raised) when the indicator is not drawn and the
  2642. radiobutton is off.
  2643. -overrelief flat|groove|raised|ridge|sunken
  2644. Alternative relief for the checkbutton when the mouse cursor is over the
  2645. widget.
  2646. -selectcolorcolor
  2647. Color used to fill in indicator when selected.
  2648. -selectimageimage
  2649. Image displayed in indicator when selected.
  2650. -valuevalue
  2651. Value given to variable specified with -variableoption when the
  2652. radiobutton is selected.
  2653. -variablevariable
  2654. Variable to associate with radiobutton.
  2655. radiobutton deselect
  2656. Deselect the radiobutton.
  2657. radiobutton flash
  2658. Alternate radiobutton between active and normal colors.
  2659. radiobutton invoke
  2660. Toggle the selection state of the radiobutton and evaluate the Tcl command
  2661. specified with -command(if present.)
  2662. radiobutton select
  2663. Select the radiobutton.
  2664. Scale
  2665. -activebackground -highlightbackground -repeatdelay
  2666. -background -highlightcolor -repeatinterval
  2667. -borderwidth -highlightthickness -state
  2668. -cursor -orient -takefocus
  2669. -font -relief -troughcolor
  2670. -foreground
  2671. -bigincrementnumber
  2672. A real value to use for large increments of the scale.
  2673. 58
  2674. Tcl/Tk Reference Guide
  2675. -commandtclCommand
  2676. Specified a TCL command to evaluate when scale’s value is changed. The
  2677. scale’s value will be appended as an additional argument.
  2678. -digitsinteger
  2679. An integer specifying how many significant digits should be retained.
  2680. -fromnumber
  2681. A real value corresponding to left or top end of the scale.
  2682. -labelstring
  2683. A string to display as label for the scale.
  2684. -lengthsize
  2685. Specifies the height (width) for vertical (horizontal) scales.
  2686. -resolutionnumber
  2687. Real value to which scale’s value will be rounded to an even multiple of.
  2688. -showvalueboolean
  2689. Whether or not scale’s current value should be displayed in side label.
  2690. -sliderlengthsize
  2691. Size of the slider, measured along the slider’s long dimension.
  2692. -sliderreliefrelief
  2693. Specify the relief used to display the slider.
  2694. -tickintervalnumber
  2695. A real value to specify the spacing between numerical tick marks displayed.
  2696. -to number
  2697. A real value corresponding to the right or bottom end of the scale.
  2698. -variablevariable
  2699. Name of a global variable to link to the scale.
  2700. -widthwidth
  2701. Narrow dimension of scale (not including border).
  2702. scale coords [value]
  2703. Returns x and y coordinates of point corresponding to value.
  2704. scale get [x y]
  2705. If x y is given, returns scale value at that coordinate position. Otherwise,
  2706. scale’s current value is returned.
  2707. scale identify x y
  2708. Returns string indicating part of scale at position x y. Maybe one of
  2709. slider, trough1, trough2or empty.
  2710. scale set value
  2711. Changes the current value of scale to value.
  2712. Scrollbar
  2713. -activebackground -highlightcolor -repeatdelay
  2714. -background -highlightthickness -repeatinterval
  2715. -borderwidth -jump -takefocus
  2716. -cursor -orient -troughcolor
  2717. -highlightbackground -relief
  2718. -activereliefnumber
  2719. Relief to use when displaying the element that is active.
  2720. 59
  2721. Tcl/Tk Reference Guide
  2722. -commandtclCommandPrefix
  2723. Prefix of a Tcl command to evaluate to change the view in the widget
  2724. associated with the scrollbar.
  2725. -elementborderwidthwidth
  2726. Width of borders around internal elements (arrows and slider).
  2727. -widthwidth
  2728. Narrow dimension of scrollbar (not including border).
  2729. Elements: arrow1, trough1, slider, trough2, arrow2
  2730. scrollbar activate [element]
  2731. Display element with active attributes.
  2732. scrollbar delta deltaX deltaY
  2733. Returns fractional position change for slider movement of deltaX deltaY.
  2734. scrollbar fraction x y
  2735. Returns a real number between 0 and 1 indicating where the point given by
  2736. pixel coords x y lies in the trough area of the scrollbar.
  2737. scrollbar get
  2738. Returns current scrollbar settings as the list {first last}.
  2739. scrollbar identify x y
  2740. Returns name of element under pixel coords x y.
  2741. scrollbar set first last
  2742. Describes current view of associated widget where first last are the
  2743. percentage distance from widget’s beginning of the start and end of the view.
  2744. Spinbox
  2745. -activebackground -highlightcolor -repeatdelay
  2746. -background -highlightthickness -repeatinterval
  2747. -borderwidth -insertbackground -selectbackground
  2748. -cursor -insertborderwidth -selectborderwidth
  2749. -disabledbackground -insertofftime -selectforeground
  2750. -disabledforeground -insertontime -state
  2751. -exportselection -insertwidth -takefocus
  2752. -font -justify -textvariable
  2753. -foreground -readonlybackground -width
  2754. -height -relief -xscrollcommand
  2755. -highlightbackground
  2756. -buttonbackgroundcolor
  2757. Background color.
  2758. -buttoncursorcursor
  2759. Cursor to be used when over the spin buttons.
  2760. -buttondownreliefrelief
  2761. Relief to be used for the upper spin button.
  2762. -buttonupreliefrelief
  2763. Relief to be used for the lower spin button.
  2764. -commandtclCommand
  2765. Command to evaluate whenever a spinbutton is invoked. Several percent
  2766. substitutions are recognized:
  2767. %W the widget path
  2768. %s the current value of the widget
  2769. 60
  2770. Tcl/Tk Reference Guide
  2771. %d the direction of the button pressed: up or down
  2772. -formatformat
  2773. Alternate format when setting the string value from the -from and -to
  2774. range. It must be valid floating-point format specifier of the form
  2775. %<pad>.<pad>f.
  2776. -fromfloat
  2777. Lowest floating-point value for a spinbox.
  2778. -incrementfloat
  2779. Floating-point adjustment to value when a spin button is pressed.
  2780. -invalidcommandtclCommand
  2781. Script to evaluate when validateCommand returns false. (Abbrev:
  2782. -invcmd).
  2783. -to float
  2784. Highest floating-point value for a spinbox.
  2785. -validatemode
  2786. Mode in which validation should operate: none (default), focus,
  2787. focusin, focusout, key, or all. See Validation above.
  2788. -validatecommandtclCommand
  2789. Evaluate tclCommand, which must return a boolean, to validate the input
  2790. into the spinbox widget. If it returns false then the addition is rejected and
  2791. will not occur, and the invalidCommand will be evaluated. (Abbrev:
  2792. -vcmd).
  2793. -valuesvalueList
  2794. Spinbox contents, starting with the first value.
  2795. -wrapboolean
  2796. Should the spinbox wrap around the values of data in the widget.
  2797. Elements: buttondown, buttonup, entry
  2798. Spinbox Indices: number, anchor, end, insert, sel.first,
  2799. sel.last,@x-coord
  2800. spinbox bbox index
  2801. Returns bounding box of character given by index.
  2802. spinbox delete first [last]
  2803. Delete characters from first through character just before last.
  2804. spinbox get
  2805. Returns the spinbox’s string.
  2806. spinbox icursor index
  2807. Display insertion cursor just before character at index.
  2808. spinbox identify x y
  2809. Returns string (one of none, buttondown, buttonupor entry)
  2810. indicating element of spinbox at position x y.
  2811. spinbox index index
  2812. Returns the numerical index corresponding to index.
  2813. spinbox insert index string
  2814. Insert string just before character at index.
  2815. spinbox invoke element
  2816. Invoke the action of the spinbox element buttondownor buttonup.
  2817. spinbox scan option args
  2818. See Widget Scroll Commands above.
  2819. 61
  2820. Tcl/Tk Reference Guide
  2821. spinbox selection adjust index
  2822. Adjust nearest end of current selection to be at index and set the other end to
  2823. the anchor point.
  2824. spinbox selection clear
  2825. Clear the selection if currently in the widget.
  2826. spinbox selection element [element]
  2827. Query or set the currently selected element. If a spinbutton element is
  2828. specified, it will be displayed depressed.
  2829. spinbox selection from index
  2830. Set the anchor point to be at index.
  2831. spinbox selection present
  2832. Returns 1 is any characters are selected, 0 otherwise.
  2833. spinbox selection range start end
  2834. Select the characters from start through character just before end.
  2835. spinbox selection to index
  2836. Set the selection to extend between index and anchor point.
  2837. spinbox set [string]
  2838. Query or set spinbox’s string.
  2839. spinbox validate
  2840. Force an evaluation of validateCommand.
  2841. spinbox xview args
  2842. See Widget Scroll Commands above.
  2843. Toplevel
  2844. -borderwidth -highlightcolor -relief
  2845. -cursor -highlightthickness -takefocus
  2846. -height -padx -width
  2847. -highlightbackground -pady
  2848. -backgroundcolor
  2849. Same as standard but my be empty to preserve colormap space.
  2850. -classstring
  2851. Class name for the window to be used by option database.
  2852. -colormapcolormap
  2853. Color map to use for window. May be the word new, pathname of other
  2854. toplevel, or empty for the default colormap of screen.
  2855. -containerboolean
  2856. Whether toplevel is a container used to embed another application.
  2857. -menupathName
  2858. Menu widget to be used as a menubar.
  2859. -screenscreen
  2860. Screen on which to place the window.
  2861. -use windowID
  2862. Toplevel should be embedded inside window identified by windowID (see
  2863. winfo id) which was created as a container.
  2864. -visualvisual
  2865. Visual to use for window.
  2866. 62
  2867. Tcl/Tk Reference Guide
  2868. 30. Images
  2869. image create type [name] [options value . . .]
  2870. Creates new image of type with options and returns name.
  2871. image delete name
  2872. Deletes the image name.
  2873. image height name
  2874. Returns pixel height of image name.
  2875. image inuse name
  2876. Returns 1 if the image is in use by any widgets, 0 otherwise.
  2877. image names
  2878. Returns a list of the names of all existing images.
  2879. image type name
  2880. Returns the type of image name.
  2881. image types
  2882. Returns a list of valid image types.
  2883. image width name
  2884. Returns pixel width of image name.
  2885. When an image is created, Tk creates a new command with the same name as the
  2886. image. For all image types, this command supports the cget and configure
  2887. methods in the same manner as widgets for changing and querying configuration
  2888. options.
  2889. The bitmap Image Type
  2890. -backgroundcolor
  2891. Set background color for bitmap.
  2892. -datastring
  2893. Specify contents of bitmap in X11 bitmap format.
  2894. -filefileName
  2895. Gives name of file whose contents define the bitmap in X11 bitmap format.
  2896. -foregroundcolor
  2897. Set foreground color for bitmap.
  2898. -maskdatastring
  2899. Specify contents of mask in X11 bitmap format.
  2900. -maskfilefileName
  2901. Gives name of file whose contents define the mask in X11 bitmap format.
  2902. The photo Image Type
  2903. -datastring
  2904. Specify contents of image in a supported format.
  2905. -formatformatName
  2906. Specify format for data specified with the -data or -fileoptions. In
  2907. standard Tk, the GIF/PGM/PPM formats are supported.
  2908. -filefileName
  2909. Specifies image data should be read from file fileName.
  2910. -gammanumber
  2911. Gamma correction. Values greater than 1 (default) lighten the image, less
  2912. than 1 darken the image.
  2913. 63
  2914. Tcl/Tk Reference Guide
  2915. -heightnumber
  2916. Fixes the height of the image to number pixels.
  2917. -palettepaletteSpec
  2918. Set the resolution of the color cube to be allocated for image.
  2919. -widthnumber
  2920. Fixes the width of the image to number pixels.
  2921. imageName blank
  2922. Blanks the image so has no data and is completely transparent.
  2923. imageName configure [option value . . .]
  2924. Query or modify the configuration options for the image. If no option is
  2925. specified, return a list describing all available options. If option is specified
  2926. with no value, return a list describing the one named option.
  2927. imageName copy sourceImage [option value . . .]
  2928. Copy a region from sourceImage to imageName using given options.
  2929. -fromx1 y1 [x2 y2]
  2930. Specifies rectangular region of source image to be copied.
  2931. -to x1 y1 [x2 y2]
  2932. Specifies rectangular region of target image to be affected.
  2933. -shrink
  2934. Will clip target image so copied region is in bottom-right corner.
  2935. -zoomx y
  2936. Magnifies source region by x y in respective direction.
  2937. -subsamplex y
  2938. Reduces source image by using only every x yth pixel.
  2939. -compositingrulerule
  2940. How transparent pixels are combined. One of overlay(default) or set.
  2941. imageName data [option value . . .]
  2942. Return image data. Options are:
  2943. -backgroundcolor
  2944. If color is specified, all transparent pixels will be replaced by color.
  2945. -formatformat-name
  2946. Specifies image format of file.
  2947. -fromx1 y1 [x2 y2]
  2948. Specifies a rectangular region of the image file to copy from.
  2949. -grayscale
  2950. All pixel data will be transformed into grayscale.
  2951. imageName get x y
  2952. Returns RGB value of pixel at coords x y as list of three integers.
  2953. imageName put data [options]
  2954. Sets pixels values to data (or single color if data is a valid color name).
  2955. Options are:
  2956. -formatformat-name
  2957. Specifies image format of data.
  2958. -fromx1 y1 [x2 y2]
  2959. Specifies a rectangular region of the image data to copy from.
  2960. -shrink
  2961. Will clip image so copied region is in bottom-right corner.
  2962. -to x y
  2963. Specifies coords of the top-left corner in image to copy into.
  2964. 64
  2965. Tcl/Tk Reference Guide
  2966. imageName read fileName [option value . . .]
  2967. Reads image data from file fileName (or single color if fileName is a valid
  2968. color name) into image using given options.
  2969. -formatformat-name
  2970. Specifies image format of file.
  2971. -fromx1 y1 x2 y2
  2972. Specifies a rectangular region of the image file to copy from.
  2973. -shrink
  2974. Will clip image so copied region is in bottom-right corner.
  2975. -to x y
  2976. Specifies coords of the top-left corner in image to copy into.
  2977. imageName redither
  2978. Redither the image.
  2979. imageName transparency get x y
  2980. Returns boolean indicating if the pixel at x y is transparent.
  2981. imageName transparency set x y boolean
  2982. Makes the pixel at x y transparent if boolean is true, opaque otherwise.
  2983. imageName write fileName [option value . . .]
  2984. Writes image data from image into file fileName.
  2985. -backgroundcolor
  2986. If color is specified, all transparent pixels will be replaced by color.
  2987. -formatformat-name
  2988. Specifies image format for the file.
  2989. -fromx1 y1 x2 y2
  2990. Specifies a rectangular region of the image to copy from.
  2991. -grayscale
  2992. All pixel data will be transformed into grayscale.
  2993. 31. Window Information
  2994. winfo atom [-displayofwindow] name
  2995. Returns integer identifier for atom given by name on window’s display.
  2996. winfo atomname [-displayofwindow] id
  2997. Returns textual name of atom given by integer id on window’s display.
  2998. winfo cells window
  2999. Returns number of cells in the colormap for window.
  3000. winfo children window
  3001. Returns list containing path names of window’s children in stacking order.
  3002. winfo class window
  3003. Returns the class name of window.
  3004. winfo colormapfull window
  3005. Return 1 if the colormap for window is full, 0 otherwise.
  3006. winfo containing [-displayofwindow] rootX rootY
  3007. Returns path name of window containing the point rootX rootY on window’s
  3008. display..
  3009. winfo depth window
  3010. Returns the depth (bits per pixel) of window.
  3011. winfo exists window
  3012. Returns 1 if window exists, 0 if it doesn’t.
  3013. 65
  3014. Tcl/Tk Reference Guide
  3015. winfo fpixels window number
  3016. Returns floating-point value giving the number of pixels in window
  3017. corresponding to the distance given by number.
  3018. winfo geometry window
  3019. Returns the pixel geometry for window, in the form widthxheight+x+y.
  3020. winfo height window
  3021. Returns height of window in pixels.
  3022. winfo id window
  3023. Returns a hexadecimal string indicating the platform identifier for window.
  3024. winfo interps [-displayofwindow]
  3025. Returns a list of all Tcl interpreters registered on window’s display.
  3026. winfo ismapped window
  3027. Returns 1 if window is currently mapped, 0 otherwise.
  3028. winfo manager window
  3029. Returns the name of the geometry manager currently responsible for
  3030. window.
  3031. winfo name window
  3032. Returns window’s name within its parent, as opposed to its full path name.
  3033. winfo parent window
  3034. Returns the path name of window’s parent.
  3035. winfo pathname [-displayofwindow] id
  3036. Returns the path name of the window whose X identifier is id on window’s
  3037. display.
  3038. winfo pixels window number
  3039. Returns the number of pixels in window corresponding to the distance given
  3040. by number, rounded to nearest integer.
  3041. winfo pointerx window
  3042. Returns mouse pointer’s x coordinate on window’s screen.
  3043. winfo pointerxy window
  3044. Returns mouse pointer’s x and y coordinates on window’s screen.
  3045. winfo pointery window
  3046. Returns mouse pointer’s y coordinate on window’s screen.
  3047. winfo reqheight window
  3048. Returns a decimal string giving window’s requested height, in pixels.
  3049. winfo reqwidth window
  3050. Returns a decimal string giving window’s requested width, in pixels.
  3051. winfo rgb window color
  3052. Returns a list of the three RGB values that correspond to color in window.
  3053. winfo rootx window
  3054. Returns the x-coordinate, in the root window of the screen, of the upper-left
  3055. corner of window (including its border).
  3056. winfo rooty window
  3057. Returns the y-coordinate, in the root window of the screen, of the upper-left
  3058. corner of window (including its border).
  3059. winfo screen window
  3060. Returns the name of the screen associated with window, in the form
  3061. displayName.screenIndex.
  3062. winfo screencells window
  3063. Returns the number of cells in the default color map for window’s screen.
  3064. 66
  3065. Tcl/Tk Reference Guide
  3066. winfo screendepth window
  3067. Returns the depth (bits per pixel) of window’s screen.
  3068. winfo screenheight window
  3069. Returns the height in pixels of window’s screen.
  3070. winfo screenmmheight window
  3071. Returns the height in millimeters of window’s screen.
  3072. winfo screenmmwidth window
  3073. Returns the width in millimeters of window’s screen.
  3074. winfo screenvisual window
  3075. Returns the visual class of window’s screen. Maybe one of:
  3076. directcolor, grayscale, pseudocolor, staticcolor,
  3077. staticgray, or truecolor.
  3078. winfo screenwidth window
  3079. Returns the width in pixels of window’s screen.
  3080. winfo server window
  3081. Returns server information on window’s display.
  3082. winfo toplevel window
  3083. Returns the pathname of the top-level window containing window.
  3084. winfo viewable window
  3085. Returns 1 if window and all its ancestors are mapped, 0 otherwise.
  3086. winfo visual window
  3087. Returns the visual class of window (see winfo screenvisual).
  3088. winfo visualid window
  3089. Returns the X identifier for the visual of window.
  3090. winfo visualsavailable window
  3091. Returns a list whose elements describe the visuals available for window’s
  3092. screen including class and depth..
  3093. winfo vrootheight window
  3094. Returns the height of the virtual root window associated with window.
  3095. winfo vrootwidth window
  3096. Returns the width of the virtual root window associated with window.
  3097. winfo vrootx window
  3098. Returns the x-offset of the virtual root window associated with window.
  3099. winfo vrooty window
  3100. Returns the y-offset of the virtual root window associated with window.
  3101. winfo width window
  3102. Returns window’s width in pixels.
  3103. winfo x window
  3104. Returns x-coordinate of the upper-left corner of window in its parent.
  3105. winfo y window
  3106. Returns y-coordinate of the upper-left corner of window in its parent.
  3107. 32. The Window Manager
  3108. wm aspect window [minNumer minDenom maxNumer maxDenom]
  3109. Query, set or cancel window’s desired aspect ratio range.
  3110. wm attributes window [option [value [option value . . .]]]
  3111. Query or set platform specific attributes for window.
  3112. 67
  3113. Tcl/Tk Reference Guide
  3114. wm client window [name]
  3115. Query, set or cancel window’s WM_CLIENT_MACHINE property which
  3116. informs window manager of client machine name on which the application
  3117. is running.
  3118. wm colormapwindows window [windowList]
  3119. Query or set window’s WM_COLORMAP_WINDOWS property which
  3120. identifies windowList windows within window with private colormaps.
  3121. wm command window [value]
  3122. Query, set or cancel window’s WM_COMMAND property. Informs
  3123. window manager of command used to invoke the application.
  3124. wm deiconify window
  3125. Arrange for window to be mapped on the screen.
  3126. wm focusmodel window [active|passive]
  3127. Query or set the focus model for window.
  3128. wm frame window
  3129. Returns the platform window identifier for the outermost decorative frame
  3130. containing window. If window has none, returns platform id of window itself.
  3131. wm geometry window [newGeometry]
  3132. Query or set geometry of window.
  3133. wm grid window
  3134. Return list containing current baseWidth baseHeight widthInc heightInc for
  3135. gridded window.
  3136. wm grid window {} {} {} {}
  3137. Indicates window is not to be managed as a gridded window.
  3138. wm grid window baseWidth baseHeight widthInc heightInc
  3139. Indicates window is to be managed as a gridded window with the specified
  3140. relation between grid and pixel units.
  3141. wm group window [pathName]
  3142. Query, set or cancel pathName of group leader for window.
  3143. wm iconbitmap window
  3144. Cancel bitmap used as icon image when window is iconified. Returns name
  3145. of previous bitmap.
  3146. wm iconbitmap window bitmap
  3147. Set bitmap to use as icon image when window is iconified.
  3148. wm iconify window
  3149. Arrange for window to be iconified.
  3150. wm iconmask window
  3151. Cancel bitmap used as mask icon image when window is iconified. Returns
  3152. name of previous bitmap.
  3153. wm iconmask window bitmap
  3154. Set bitmap to use to mask icon image when window is iconified.
  3155. wm iconname window [newName]
  3156. Query or set name to use as a label for window’s icon.
  3157. wm iconposition window [x y]
  3158. Query, set or cancel hint for position on root window to place window’s icon.
  3159. wm iconwindow window [pathName]
  3160. Query, set or cancel pathName of window to use as the icon when window is
  3161. iconified.
  3162. wm maxsize window [width height]
  3163. Query or set maximum size that window may be resized to in each direction.
  3164. 68
  3165. Tcl/Tk Reference Guide
  3166. wm minsize window [width height]
  3167. Query or set minimum size that window may be resized to in each direction.
  3168. wm overrideredirect window [boolean]
  3169. Query or set the override-redirect flag of window commonly used by window
  3170. manager to determine whether window should have a decorative frame.
  3171. wm positionfrom window [program|user]
  3172. Indicate from whom the window’s current position was requested.
  3173. wm protocol window
  3174. Return list of all protocols for which window has handlers.
  3175. wm protocol window name
  3176. Return current command associated with window for messages of protocol
  3177. name.
  3178. wm protocol window name {}
  3179. Cancel handler associated with window for messages of protocol name.
  3180. wm protocol window name command
  3181. Specify a Tcl command as handler of name protocol messages for window.
  3182. wm resizable topWindow [widthBoolean heightBoolean]
  3183. Query or set whether topWindow’s width and/or height is resizable.
  3184. wm sizefrom window [program|user]
  3185. Indicate from whom the window’s current size was requested.
  3186. wm stackorder window
  3187. Return a list of toplevel windows in stacking order, from lowest to highest.
  3188. wm stackorder window1 isabove|isbelowwindow2
  3189. Return boolean indicating if window1 is currently above or below window2
  3190. in the stacking order.
  3191. wm state window [newstate]
  3192. Query or set current state of window: normal, icon, iconic, or
  3193. withdrawn.
  3194. wm title window [string]
  3195. Query or set string as title for window’s decorative frame.
  3196. wm transient window
  3197. Return current master window if window is a transient window.
  3198. wm transient window {}
  3199. Inform window manager that window is not a transient window.
  3200. wm transient window [master]
  3201. Inform window manager that window is a transient of window master.
  3202. wm withdraw window
  3203. Arranges for window to be withdrawn from the screen.
  3204. 33. Binding and Virtual Events
  3205. bind tag
  3206. Returns list of all sequences for which a bindings exists for tag.
  3207. bind tag sequence
  3208. Returns the script bound to the given sequence for tag.
  3209. bind tag sequence tclCommand
  3210. Binds tclCommand to the given sequence for tag. If tclCommand is the
  3211. empty string, the binding is deleted. If the first character of tclCommand is a
  3212. +, then it is appended to the currently associated script. Does %-substitution
  3213. on tclCommand (See Event Fields below)
  3214. 69
  3215. Tcl/Tk Reference Guide
  3216. bindtags window [tagList]
  3217. Sets the current precedence order of tags for window to tagList. If tagList is
  3218. an empty list, the tags are set back to the defaults.
  3219. event add <<virtual>> sequence [sequence . . . ]
  3220. Arrange for virtual event <<virtual>>to be triggered when anyone of given
  3221. sequences occur.
  3222. event delete <<virtual>> [sequence . . . ]
  3223. Deletes given sequences (or all if none given) from list that triggers the
  3224. virtual event <<virtual>>.
  3225. event generate window event [-whenwhen] [option value . . . ]
  3226. Generate event in window as if it came from window system. Possible
  3227. options are listed in the Event Field table below. The -when option sets
  3228. when the event will be processed. Possible values for when are:
  3229. now process immediately (default)
  3230. tail place at end of event queue
  3231. head place at beginning of event queue
  3232. mark same as head but behind previous generated events
  3233. event info [<<virtual>>]
  3234. Returns list of sequences that trigger virtual event <<virtual>>(if not given,
  3235. returns list of defined virtual events).
  3236. The sequence argument is a list of one or more event patterns. An event pattern
  3237. may be a single ASCII character, a string of the form
  3238. <modifier-modifier-type-detail>, or <<name>>(virtual event).
  3239. Modifiers:
  3240. Alt Button4, B4 Meta, M Mod5, M5
  3241. Any Button5, B5 Mod1, M1 Quadruple
  3242. Button1, B1 Control Mod2, M2 Shift
  3243. Button2, B2 Double Mod3, M3 Triple
  3244. Button3, B3 Lock Mod4, M4
  3245. Types:
  3246. Activate Destroy Map
  3247. ButtonPress, Button Enter MapRequest
  3248. ButtonRelease Expose Motion
  3249. Circulate FocusIn MouseWheel
  3250. CirculateRequest FocusOut Property
  3251. Colormap Gravity Reparent
  3252. Configure KeyPress, Key ResizeRequest
  3253. ConfigureRequest KeyRelease Unmap
  3254. Create Leave Visibility
  3255. Deactivate
  3256. Details: for buttons, a number 15
  3257. for keys, a keysym (/usr/include/X11/keysymdef)
  3258. Tags: internal window (applies to just that window)
  3259. toplevel window (applies to all its internal windows)
  3260. window class name (applies to all widgets in class)
  3261. all (applies to all windows)
  3262. Event Fields:
  3263. Generate Option Code Valid Events
  3264. %% Single ‘%’
  3265. 70
  3266. Tcl/Tk Reference Guide
  3267. -abovewindow %a Configure
  3268. -borderwidthsize %B §, Configure
  3269. -buttonnumber %b ButtonPress, ButtonRelease
  3270. -countnumber %c Expose
  3271. -deltanumber %D MouseWheel
  3272. -detaildetail %d ‡, ConfigureRequest, Focus
  3273. -focusboolean %f ‡
  3274. -heightsize %h §, Expose, ResizeRequest
  3275. %i Window field all events
  3276. -keycodenumber %k %A KeyPress, KeyRelease
  3277. -keysymname %K %A %N KeyPress, KeyRelease
  3278. -mode notify %m ‡, Focus
  3279. -overrideboolean %o Configure, Map, Reparent
  3280. -placewhere %p Circulate, CirculateRequest
  3281. -rootwindow %R †,
  3282. -rootxcoord %X †,
  3283. -rootycoord %Y †,
  3284. -sendeventboolean %E all events
  3285. -serialnumber %# all events
  3286. -statestate %s †,, Visibility
  3287. -subwindowwindow %S †,
  3288. -time integer %t †,, Property
  3289. %T Type field all events
  3290. -warp boolean †
  3291. -widthsize %w §, Configure, Expose,
  3292. ResizeRequest
  3293. %W path name all events
  3294. -x coord %x †,, Configure, Expose,
  3295. Gravity, Reparent
  3296. -y coord %y †,, Configure, Expose,,
  3297. Gravity, Reparent
  3298. † ButtonPress, ButtonRelease, KeyPress,
  3299. KeyRelease, Motion
  3300. ‡ Enter, Leave
  3301. § ConfigureRequest, Create
  3302. 34. Geometry Management
  3303. The pack Command
  3304. pack [configure] slave [slave . . .] [options]
  3305. Sets how slave windows should be managed by pack geometry master.
  3306. -aftersibling -fill none|x|y|both
  3307. -anchoranchor -in master
  3308. -beforesibling -side top|bottom|left|right
  3309. -expandboolean
  3310. -ipadxpixels
  3311. How much horizontal internal padding to leave on each side of the slave(s).
  3312. -ipadypixels
  3313. How much vertical internal padding to leave on on the top and bottom of the
  3314. slave(s).
  3315. 71
  3316. Tcl/Tk Reference Guide
  3317. -padxpixels
  3318. How much horizontal external padding to leave on each side of the slave(s).
  3319. -padx{leftPixels rightPixels}
  3320. How much horizontal external padding to leave on the left and right side of
  3321. the slave(s).
  3322. -padypixels
  3323. How much vertical external padding to leave on the top and bottom of the
  3324. slave(s).
  3325. -pady{topPixels bottomPixels}
  3326. How much vertical external padding to leave on the top and bottom of the
  3327. slave(s).
  3328. pack forget slave [slave . . .]
  3329. Unmanages the given slave windows.
  3330. pack info slave
  3331. Returns list containing current pack configuration of window slave.
  3332. pack propagate master [boolean]
  3333. Enables or disables propagation for the window master.
  3334. pack slaves master
  3335. Returns lists of slaves in the window master.
  3336. The place Command
  3337. place window option value [option value . . .]
  3338. Sets how window should be placed inside its master.
  3339. place [configure] window [option [value [option value . . .]]]
  3340. Query or modify how window should be placed inside its master.
  3341. -anchoranchor -relheightsize -rely location
  3342. -heightsize -relwidthsize -x location
  3343. -in master -relx location -y location
  3344. -widthsize -bordermode inside|outside|ignore
  3345. -bordermodemode
  3346. Degree to which borders within master determine placement of slave. One
  3347. of inside(default), outsideor ignore.
  3348. place forget window
  3349. Unmanages window.
  3350. place info window
  3351. Returns list containing current place configuration of window.
  3352. place slaves window
  3353. Returns lists of slaves in the window master.
  3354. The grid Command
  3355. grid [configure] slave|x|∧ [slave|x|∧ . . . ] [option value . . .]
  3356. Sets how slave windows should be managed by grid geometry master.
  3357. -columnspann -in other -row n
  3358. -columnn -rowspann -sticky[n][s][e][w]
  3359. -ipadxpixels
  3360. How much horizontal internal padding to leave on each side of the slave(s).
  3361. 72
  3362. Tcl/Tk Reference Guide
  3363. -ipadypixels
  3364. How much vertical internal padding to leave on on the top and bottom of the
  3365. slave(s).
  3366. -padxpixels
  3367. How much horizontal external padding to leave on each side of the slave(s).
  3368. -padx{leftPixels rightPixels}
  3369. How much horizontal external padding to leave on the left and right side of
  3370. the slave(s).
  3371. -padypixels
  3372. How much vertical external padding to leave on the top and bottom of the
  3373. slave(s).
  3374. -pady{topPixels bottomPixels}
  3375. How much vertical external padding to leave on the top and bottom of the
  3376. slave(s).
  3377. grid bbox master [column row [column2 row2]]
  3378. Returns bounding box in pixels of space occupied by whole grid (no args),
  3379. the cell (2 args), or area spanning between given cells (4 args).
  3380. grid columnconfigure master columnList [options]
  3381. Set/query column properties of given columns in grid master.
  3382. -minsizesize Minimum size of column.
  3383. -pad amount Padding to add to sides of largest slave.
  3384. -uniformtag Groups column with others having same tag (an arbitrary
  3385. string). Apportions space for all in the group in strict
  3386. proportion to their weights.
  3387. -weightint Relative weight for apportioning extra space.
  3388. grid forget slave [slave . . . ]
  3389. Removes (and unmaps) each slave from grid forgetting its configuration.
  3390. grid info slave
  3391. Returns list describing configuration state of slave.
  3392. grid location master x y
  3393. Returns column and row containing screen units x y in master. If x y is
  3394. outside grid, -1 is returned.
  3395. grid propagate master [boolean]
  3396. Set/query whether master tries to resize its ancestor windows to fit grid.
  3397. grid remove slave [slave . . . ]
  3398. Removes (and unmaps) each slave from grid remembering its configuration.
  3399. grid rowconfigure master rowList [options]
  3400. Set/query row properties of given rows in grid master. Same options as for
  3401. columnconfigure but for rows.
  3402. grid size master
  3403. Returns size of grid (as columns rows) for master.
  3404. grid slaves master [-row row] [-columncolumn]
  3405. With no options, a list of all slaves in master is returned. Otherwise, returns
  3406. a list of slaves in specified row or column.
  3407. Grid Relative Placement
  3408. - Increases columnspan of slave to the left.
  3409. x Leave an empty column.
  3410. ∧ Extends the rowspan of slave above.
  3411. 73
  3412. Tcl/Tk Reference Guide
  3413. 35. Fonts
  3414. font actual fontDesc [-displayofwindow] [option]
  3415. Returns actual value for option used by fontDesc on window’s display. If
  3416. option is not given, the complete option/actual value list is returned.
  3417. font configure fontname [option [value option value . . . ]]
  3418. Query/set font options for application created font fontname.
  3419. font create [fontname [option value . . . ]]
  3420. Create new application font fontname with given font options.
  3421. font delete fontname [fontname . . . ]
  3422. Delete given application created fonts.
  3423. font families [-displayofwindow]
  3424. Returns list of know font families defined on window’s display.
  3425. font measure fontDesc [-displayofwindow] text
  3426. Returns width in pixels used by text when rendered in fontDesc on window.
  3427. font metrics fontDesc [-displayofwindow] [metric]
  3428. Query font metrics of fontDesc on window’s display where metric maybe be
  3429. one of -ascent, -descent, -linespace, or -fixed. If metric is not
  3430. given, the complete metric/value list is returned.
  3431. font names
  3432. Returns list of application created fonts.
  3433. Font Description:
  3434. 1. fontname
  3435. Name of font created by the application with font create.
  3436. 2. systemfont
  3437. Name of platform-specific font interpreted by graphics server.
  3438. 3. family [size [style . . . ]]
  3439. A Tcl list with first element the name of a font family, the optional second
  3440. element is desired size, and additional elements chosen from normalor
  3441. bold, romanor italic, underlineand overstrike.
  3442. 4. X-font name
  3443. A Unix-centric font name of the form
  3444. -foundry-family-weight-slant-setwidth-addstyle-pixel-point-resx-resyspacing-width-charset-encoding. The ‘*’ character may be used as a wild
  3445. card.
  3446. 5. option value [option value . . . ]
  3447. A Tcl list of option/values as valid for font create.
  3448. Font Options:
  3449. -familyname Font family (e.g. Courier, Times, Helvetica).
  3450. -sizesize Size in points (or pixels if negative).
  3451. -weightweight Either normal(default) or bold.
  3452. -slantslant Either roman(default) or italic.
  3453. -underlineboolean Whether or not font is underlined.
  3454. -overstrikeboolean Whether or not font is overstriked.
  3455. 36. Other Tk Commands
  3456. bell [-displayofwindow] [-nice]
  3457. Ring the X bell on window’s display. The -nice option will attempt to
  3458. 74
  3459. Tcl/Tk Reference Guide
  3460. avoid waking the screen saver.
  3461. clipboard clear [-displayofwindow]
  3462. Claim ownership of clipboard on window’s (default ‘.’) display, clearing its
  3463. contents.
  3464. clipboard append [-displayofwindow] [-formatfmt] [-type type] data
  3465. Append data of type (default STRING) to clipboard on window’s (default
  3466. ‘.’) display.
  3467. clipboard get [-displayofwin] [-type type]
  3468. Retrieve the clipboard on win’s (default ‘.’) display as type (default
  3469. STRING).
  3470. destroy [window window . . .]
  3471. Destroy the given windows and their descendents.
  3472. focus [-force] window
  3473. Sets the input focus for window’s display to window. The -forceoption
  3474. cause the focus to be set even if another application has it.
  3475. focus [-displayofwindow]
  3476. Returns name of focus window on window’s display.
  3477. focus -lastforwindow
  3478. Returns the window which most recently had focus and is a descendent of
  3479. window’s toplevel .
  3480. grab current [window]
  3481. Returns name of current grab window on window’s display. If window is
  3482. omitted, returns list of all windows grabbed by application.
  3483. grab release window
  3484. Releases grab on window.
  3485. grab [set] [-global] window
  3486. Sets a grab on window which will be local unless -globalspecified.
  3487. grab status window
  3488. Returns none, local, or globalto describe grab state of window.
  3489. ::safe::loadTk slave [-use window] [-displaydisplayName]
  3490. Initialize the required data structures in the safe interpreter slave and then
  3491. load Tk into it.
  3492. lower window [belowThis]
  3493. Places window below window belowThis in stacking order.
  3494. option add pattern value [priority]
  3495. Adds option with pattern value at priority (0100) to database.
  3496. option clear
  3497. Clears option database and reloads from user’s Xdefaults.
  3498. option get window name class
  3499. Obtains option value for window under name and class if present.
  3500. option readfile fileName [priority]
  3501. Reads options from Xdefaults-style file into option database at priority.
  3502. raise window [aboveThis]
  3503. Places window above window aboveThis in stacking order.
  3504. selection clear [-displayofwindow] [-selectionselection]
  3505. Clears selection (default PRIMARY) on window’s display.
  3506. selection get [-displayofwindow] [-selectionselection] [-type type]
  3507. Retrieves selection from window’s display using representation type.
  3508. selection handle [-selectionsel] [-type type] [-formatfmt] win cmd
  3509. Arranges for cmd to be run whenever sel of type is owned by win.
  3510. 75
  3511. Tcl/Tk Reference Guide
  3512. selection own [-displayofwindow] [-selectionselection]
  3513. Returns path name of window which owns selection on window’s display.
  3514. selection own [-selectionselection] [-commandcommand] window
  3515. Causes window to become new owner of selection and arranges for
  3516. command to be run when window later loses the selection.
  3517. send [-displayofwindow] [-async] interp cmd [arg arg . . .]
  3518. Evaluate cmd with args in the Tk application interp on window’s display. If
  3519. -asyncis specified, the send command will return immediately.
  3520. tk appname [newName]
  3521. Set the interpreter name of the application to newName.
  3522. tk caret window [option value . . . ]
  3523. Query or set accessibility caret location for display of window. Options are:
  3524. -x pixels Window-relative X coordinate.
  3525. -y pixels Window-relative Y coordinate.
  3526. -heightpixels Height of window or cursor.
  3527. tk scaling [-displayofwindow] [floatNumber]
  3528. Set scaling factor for conversion between physical units and pixels on
  3529. window’s display where floatNumber is pixels per point ( 1/72 inch).
  3530. tk useinputmethods [-displayofwindow] [boolean]
  3531. Sets and queries whether Tk should use XIM (X Input Methods) for filtering
  3532. events. The resulting state is returned. Default is true for the main display.
  3533. tk windowingsystem
  3534. Returns one of x11, win32, classicor aqua.
  3535. tkwait variable varName
  3536. Pause program until global variable varName is modified.
  3537. tkwait visibility window
  3538. Pause program until window’s visibility has changed.
  3539. tkwait window window
  3540. Pause program until window is destroyed.
  3541. tk_bisque
  3542. Set default color palette to old bisque scheme.
  3543. tk_chooseColor [option value . . . ]
  3544. Pops up dialog for user to choose color and returns choice. Options are:
  3545. -initialcolorcolor Makes default choice color.
  3546. -parentwindow Makes window parent of dialog.
  3547. -titlestring Makes string title of dialog window.
  3548. tk_chooseDirectory [option value . . . ]
  3549. Pops up dialog for user to select a directory and returns choice. Options are:
  3550. -initialdirdirname Makes initial directory dirname.
  3551. -parentwindow Makes window parent of dialog.
  3552. -titlestring Makes string title of dialog window.
  3553. -mustexistboolean May non-existent directories be
  3554. chosen?
  3555. tk_dialog topw title text bitmap default string [string . . .]
  3556. Pops up dialog using toplevel window topw with a button for each string
  3557. argument. Returns index of button user presses, starting from 0 for the
  3558. leftmost button. The index default specifies the default button.
  3559. tk_focusNext window
  3560. Returns the next window after window in focus order.
  3561. 76
  3562. Tcl/Tk Reference Guide
  3563. tk_focusPrev window
  3564. Returns the previous window before window in focus order.
  3565. tk_focusFollowsMouse
  3566. Change focus model of application so focus follows the mouse pointer.
  3567. tk_getOpenFile [option value . . . ]
  3568. Pops up dialog for user to choose an existing filename and returns choice.
  3569. Options are:
  3570. -defaultextensionextension
  3571. String to append to filename if no extensions exists on chosen
  3572. filename.
  3573. -filetypesfilePatternList
  3574. List of filepattern elements of the form
  3575. typeName {extension [extension . . . ]} [{macType . . . }]
  3576. -initialdirdirectory Display files in directory.
  3577. -initialfilefileName Make default choice fileName.
  3578. -multipleboolean Allow choice of multiple files.
  3579. -parentwindow Makes window parent of dialog.
  3580. -titlestring Makes string title of dialog window.
  3581. tk_getSaveFile [option value . . . ]
  3582. Pops up dialog for user to choose a filename and returns choice. Options are
  3583. same as for tk_getOpenFile.
  3584. tk_menuSetFocus menuWindow
  3585. Save the current focus and sets the focus to menuWindow. menu name.
  3586. tk_messageBox [option value . . . ]
  3587. Displays a message dialog and returns the unique symbolic name of button
  3588. pressed by user. Options are:
  3589. -defaultname Make button name the default.
  3590. -messagestring Display string as dialog’s message.
  3591. -parentwindow Makes window parent of dialog.
  3592. -titlestring Makes string title of dialog window.
  3593. -icon error|info|question|warning
  3594. Adds specified icon to dialog.
  3595. -type buttonSet
  3596. One of abortretryignore, ok, okcancel, retrycancel,
  3597. yesno or yesnocancel.
  3598. tk_optionMenu w varName value [value . . .]
  3599. Creates option menu with name w consisting of the given values. The current
  3600. value is stored in global variable varName. Returns internal menu name.
  3601. tk_popup menu x y [entry]
  3602. Post popup menu so that entry is positioned at root coords x y.
  3603. tk_setPalette color
  3604. Changes the color scheme for Tk so the default background color is color
  3605. and other default colors are computed.
  3606. tk_setPalette name color [name color . . . ]
  3607. Set the default color for the named options in the color scheme explicitly.
  3608. Possible options are:
  3609. activeBackground highlightColor
  3610. activeForeground insertBackground
  3611. background selectColor
  3612. disabledForeground selectBackground
  3613. 77
  3614. Tcl/Tk Reference Guide
  3615. foreground selectForeground
  3616. highlightBackground troughColor
  3617. tk_textCopy window
  3618. The default binding for the copy key for the text widget.
  3619. tk_textCut window
  3620. The default binding for the cut key for the text widget.
  3621. tk_textPaste window
  3622. The default binding for the paste key for the text widget.
  3623. 78
  3624. Tcl/Tk Reference Guide
  3625. 37. TclX 8.4
  3626. The TclX package extends Tcl’s capabilities by adding new commands. Package
  3627. command is:
  3628. package require Tclx
  3629. 38. TclX Special Variables and Commands
  3630. tclx_library Path to the TclX runtime library.
  3631. TCLXENV Array containing information private to TclX.
  3632. mainloop The procedure which sets up a top-level event loop.
  3633. 39. TclX General Commands
  3634. dirs List the directories in the directory stack.
  3635. commandloop options
  3636. Create an interactive command loop reading from stdinand writing
  3637. results to stdout. In interactive mode, the results of a set command with
  3638. two arguments is not printed.
  3639. If SIGINTis configured to generate a Tcl error, it can be used to delete the
  3640. current command being typed without aborting the program in progress.
  3641. Options are:
  3642. -async
  3643. Read from stdin until a complete command is available, evaluating
  3644. it at that point.
  3645. -interactivemode
  3646. Enable or disable interactive command mode. Mode is one of:
  3647. on Enable
  3648. off Disable
  3649. tty Enable if stdinis associated with a terminal (default)
  3650. -prompt1tclCommand
  3651. Use the result of evaluating tclCommand as the main command
  3652. prompt, otherwise evaluate $tcl_prompt1.
  3653. -prompt2tclCommand
  3654. Use the result of evaluating tclCommand as the continuation
  3655. command prompt, otherwise evaluate $tcl_prompt2.
  3656. -endcommandtclCommand
  3657. Evaluate tclCommand when the command loop terminates.
  3658. echo [string . . . ]
  3659. Write each string (separated by a space) and a final newline to stdout.
  3660. infox version
  3661. Return TclX version number.
  3662. infox patchlevel
  3663. Return TclX patch level.
  3664. infox have_fchown
  3665. Return 1 if the fchownsystem call is available, 0 otherwise.
  3666. 79
  3667. Tcl/Tk Reference Guide
  3668. infox have_fchmod
  3669. Return 1 if the fchmodsystem call is available, 0 otherwise.
  3670. infox have_flock
  3671. Return 1 if the flock system call is available, 0 otherwise.
  3672. infox have_fsync
  3673. Return 1 if the fsync system call will sync individual files, 0 otherwise.
  3674. infox have_ftruncate
  3675. Return 1 if the ftruncatesystem call is available, 0 otherwise.
  3676. infox have_msgcats
  3677. Return 1 if XPG message catalogs are available, 0 if not.
  3678. infox have_posix_signals
  3679. Return 1 if Posix signals are available, 0 otherwise.
  3680. infox have_signal_restart
  3681. Return 1 if restartable signals are available, 0 if not.
  3682. infox have_truncate
  3683. Return 1 if the truncatesystem call is available, 0 otherwise.
  3684. infox have_waitpid
  3685. Return 1 if the waitpidsystem call is available, 0 otherwise.
  3686. infox appname
  3687. Return the value of the C variable tclAppName.
  3688. infox applongname
  3689. Return the value of the C variable tclLongAppName.
  3690. infox appversion
  3691. Return the value of the C variable tclAppVersion.
  3692. infox apppatchlevel
  3693. Return the value of the C variable tclAppPatchlevel.
  3694. for_array_keys varName arrayName tclCommand
  3695. Shortcut for: foreach varName [array names arrayName] tclCommand
  3696. for_recursive_glob varName dirList globList tclCommand
  3697. Recursively search dirList (but do not follow symbolic links) using patterns
  3698. in globList. Evaluate tclCommand for each file matched setting varName to
  3699. the name of the file.
  3700. loop varName firstValue limitValue [increment] tclCommand
  3701. Shortcut for: for {set varName firstValue}
  3702. {$varName compare $limitValue}
  3703. {incr varName increment}
  3704. tclCommand
  3705. If increment (default 1) is negative, the loop counts down. The values of
  3706. firstValue, limitValue and increment are integer expressions only evaluated
  3707. once at the beginning of the loop.
  3708. popd
  3709. Pop the top entry from the directory stack and make it the current directory.
  3710. pushd [dirName]
  3711. Push the current directory onto the directory stack and cd to dirName
  3712. (default [pwd].)
  3713. recursive_glob dirList globList
  3714. Recursively search dirList (but do not follow symbolic links) using patterns
  3715. in globList. Return a list of all files matched.
  3716. showproc [procName . . . ]
  3717. Show the definition of procName (default is all loaded procedures.)
  3718. 80
  3719. Tcl/Tk Reference Guide
  3720. try_eval tclCommand catchCommand [finalCommand]
  3721. Evaluate tclCommand in the current context. If an error occurs and
  3722. catchCommand is not empty, then catchCommand is evaluated and its result
  3723. becomes the result of try_eval. The context of catchCommand includes the
  3724. global variables:
  3725. errorResult The result, including the error message, of tclCommand
  3726. errorCode As set by Tcl
  3727. errorInfo As set by Tcl
  3728. If the error is to be continued, use the following command
  3729. error $errorResult $errorCode $errorInfo
  3730. If finalCommand is not empty, it is evaluated after tclCommand and
  3731. catchCommand. If an error occurs within finalCommand, then it becomes
  3732. the result of the try_eval command.
  3733. 40. TclX Debugging Commands
  3734. cmdtrace level options
  3735. cmdtrace on options
  3736. Trace commands executed depth below or at level, or all commands for on.
  3737. Options are:
  3738. noeval Print arguments unevaluated, otherwise evaluated.
  3739. notruncate Do not truncate trace lines to 60 characters.
  3740. procs Trace procedure calls only.
  3741. fileId Write trace output to fileId rather than stdout.
  3742. commandtclProc
  3743. For each line traced, call tclProc with arguments:
  3744. command The command before any argument
  3745. substitution.
  3746. argv Final argument list.
  3747. evalLevel Call level.
  3748. procLevel Procedure call level.
  3749. Tracing is turned off during tclProc execution. The values of
  3750. errorInfoand errorCodeare saved and restored on
  3751. return from tclProc.
  3752. cmdtrace off
  3753. Disable tracing.
  3754. cmdtrace depth
  3755. Returns the current maximum trace level, or zero if trace is disabled.
  3756. 41. TclX Development Commands
  3757. edprocs [procName . . . ]
  3758. Write procName (default all defined procedures) to a temporary file, invoke
  3759. the editor specified by $env(EDITOR)(default vi), and then source the
  3760. file if it was changed.
  3761. profile [-commands] [-eval] on
  3762. Collect performance data by procedure name. If -commandsis specified,
  3763. include data for Tcl commands as well. For -eval, the call stack rather
  3764. than the procedure scope stack is used to group statistics.
  3765. 81
  3766. Tcl/Tk Reference Guide
  3767. profile off profDataVar
  3768. Terminate profiling and store the results in profDataVar.
  3769. profrep profDataVar sortKey [fileId] [title]
  3770. Generates a report from profDataVar collected by the profile command
  3771. writing to fileId (default stdout) with optional title. The sortKey (one of
  3772. calls, cpu or real) indicates how to sort the data.
  3773. saveprocs fileName [procName . . . ]
  3774. Saves procName (if omitted, all defined procedures) to fileName.
  3775. 42. TclX Unix Access Commands
  3776. alarm float
  3777. Schedule a SIGALRMto be signaled after float seconds have elapsed. If float
  3778. is zero, cancel any previous request. Returns the number of seconds left in
  3779. the previous alarm.
  3780. execl [-argv0argv0] progName [argList]
  3781. Do an execl, replacing the current program, with progName passing
  3782. arguments argList. The -argv0option specifies an alternate value for
  3783. argv[0].
  3784. chroot dirName
  3785. Invoke the chroot(2) system call.
  3786. fork
  3787. Fork the current Tcl process, returning zero to the child and the child’s
  3788. process number to the parent.
  3789. id user [name]
  3790. id userid [uid]
  3791. Query or set the real and effective user ID.
  3792. id convert userid uid
  3793. id convert user name
  3794. Convert user ID number to a user name, or vice versa.
  3795. id group [name]
  3796. id groupid [gid]
  3797. Query or set the real and effective group ID.
  3798. id groups
  3799. id groupids
  3800. Return the current group names or ID numbers.
  3801. id convert groupid gid
  3802. id convert group name
  3803. Convert group ID number to a group name, or vice versa.
  3804. id effective user
  3805. id effective userid
  3806. Return the effective user name or ID number.
  3807. id effective group
  3808. id effective groupid
  3809. Return the effective group name or ID number.
  3810. id host
  3811. Same as info hostname.
  3812. id process
  3813. Same as pid.
  3814. id process parent
  3815. Return the parent process ID of the current process.
  3816. 82
  3817. Tcl/Tk Reference Guide
  3818. id process group
  3819. Return the group ID of the current process.
  3820. id process group set
  3821. Set the process group ID of the current process to its process ID.
  3822. kill [-pgroup] [signal] pidList
  3823. Send signal (default SIGTERM) to the each process in pidList or process
  3824. group for -pgroup. If present, signal is either the signal number or the
  3825. symbolic name.
  3826. link [-sym] srcPath destPath
  3827. Same as file link.
  3828. nice [priorityincr]
  3829. Query or set the process priority. Return the current priority.
  3830. readdir [-hidden] dirPath
  3831. Returns a list containing the contents (except for ”.” and ”..”) of directory
  3832. dirPath.
  3833. signal [-restart] action sigList [tclCommand]
  3834. Specify action to take when Unix signal sigList (numbers, symbolic names
  3835. or * for all signals) is received. Use -restartto restart blocking system
  3836. calls if action is not error. Action is one of:
  3837. default Perform system default action.
  3838. ignore Ignore the signal.
  3839. error Generate a catchable Tcl error with $errorCodeset to
  3840. SIGNAME.
  3841. trap Evaluate tclCommand and continue if an error is not returned.
  3842. Percent substitution is done for \%S (the signal name).
  3843. get Return current settings of sigList as a keyed list of signal names
  3844. and values, where each value is a list:
  3845. action default, ignore, error or trap
  3846. 0 or 1 0 if not blocked, 1 if blocked
  3847. tclCommand If action is trap
  3848. flag indicates if -restartis set
  3849. set Set signals from a keyed list in the format returned by get.
  3850. block Block the specified signals.
  3851. unblock Unblock the specified signals.
  3852. sleep integer
  3853. The process will sleep for integer seconds.
  3854. system command1 [command2 . . . ]
  3855. Concatenates commands with a space, then evaluate the result using the
  3856. standard system shell. The exit code of the command is returned.
  3857. sync [fileId]
  3858. Invoke the sync(2), or fsync(2) if fileId is specified, system call.
  3859. times
  3860. Return a list of the process and child execution times (milliseconds):
  3861. utime stime cutime cstime
  3862. umask [octalmask]
  3863. Set or query the file-creation mask.
  3864. wait [-nohang] [-untraced] [-pgroup] [pid]
  3865. Wait for termination of any (or specific pid) process created with execl. For
  3866. -nohang, don’t block but return an empty list if no process has terminated.
  3867. 83
  3868. Tcl/Tk Reference Guide
  3869. For -untraced, then the status of stopped children whose status has not
  3870. yet been reported are also returned. If -pgroupis specified and pid is not,
  3871. then wait on any process whose process groupd ID is they same as the
  3872. calling process. If both -pgroupand pid are specified, interpret pid as a
  3873. process group ID.
  3874. Return a three-element list:
  3875. {pid EXIT exitCode} The process exited normally
  3876. {pid SIG signalName} The process terminated due to a signal
  3877. {pid STOP signalName} The process is currently stopped
  3878. 43. TclX File Commands
  3879. bsearch fileId key [varName] [cmpProc]
  3880. Search fileId, an ASCII file sorted in ascending order, for a match using key
  3881. and the first white-space delimited field on a line. If varName is omitted,
  3882. return the matched line. Otherwise return 1 for a match (0 if no match) with
  3883. the line stored in varName.
  3884. If cmpProc is specified, evaluate it with arguments key and line. The
  3885. procedure must return -1, 0 or 1 depending on the comparison.
  3886. chmod [-fileid] mode fileList
  3887. Set permissions of files (or fileIds for -fileid) specified in fileList to
  3888. mode. Mode can be either numberic or symbolic.
  3889. chown [-fileid] idList fileList
  3890. Set owner of files (or fileIds for -fileid) as specified in fileList. The list
  3891. idList contains one or two elements: a user name or number and group
  3892. name, number or {} (indicating the login group). If no second element,
  3893. group ownership is unaltered.
  3894. chgrp [-fileid] group fileList
  3895. Set group ownership of files (or fileIds for -fileid) specified in fileList.
  3896. The group is a group name or number.
  3897. dup fileId [targetFileId]
  3898. Duplicate fileId (or a number) returning a new fileId. If targetFileId is
  3899. specified, the original file is closed.
  3900. fcntl fileId attribute [value]
  3901. Query or set file options (boolean) for fileId. Attributes are:
  3902. RDONLY opened for input (query only)
  3903. WRONLY opened for output (query only)
  3904. RDWR opened for input and output (query only)
  3905. READ readable (query only)
  3906. WRITE writable (query only)
  3907. APPEND opened for append-only output
  3908. NONBLOCK same as fconfigure -blocking
  3909. CLOEXEC close on exec flag
  3910. NOBUF same as fconfigure -buffering
  3911. LINEBUF same as fconfigure -buffering
  3912. KEEPALIVE keep a socket connection alive.
  3913. flock switches fileId [start] [length] [origin]
  3914. Lock all (or part from start (default 0) for length relative to origin) of fileId.
  3915. 84
  3916. Tcl/Tk Reference Guide
  3917. If length is omitted or 0, lock extends to the end of the file. Origin is one of
  3918. start (default), currentor end. Switches are:
  3919. -read create a read lock
  3920. -write create a write lock
  3921. -nowait return 1 if the lock is obtained, 0 otherwise
  3922. for_file varName filename tclCommand
  3923. Loop over lines in filename evaluating tclCommand with varName set to
  3924. each line of the file.
  3925. funlock fileId [start] [length] [origin]
  3926. Remove all (or part from start (default 0) for length relative to origin) of a
  3927. lock placed on fileId with flock.
  3928. fstat fileId stat [arrayVar]
  3929. Same as file stat with an additional item key tty. Its value is 1 if fileId is
  3930. associated with a terminal and 0 otherwise. If arrayVar is omitted, return a
  3931. key-value list.
  3932. fstat fileId [item]
  3933. Return individual (identified by item) result of stat on fileId. Item identifiers
  3934. are the same as above.
  3935. fstat fileId localhost
  3936. For a socket connection, return a list containing the local IP address,
  3937. hostname and port number.
  3938. fstat fileId remotehost
  3939. For a socket connection, return a list containing the remote IP address,
  3940. hostname and port number.
  3941. ftruncate [-fileid] file newsize
  3942. Truncate files (or fileIds for -fileid) specified in fileList to newsize.
  3943. lgets fileId [varName]
  3944. Read a Tcl list from fileId discarding the final newline. If varName is
  3945. omitted, return the list. Otherwise return the number of characters read and
  3946. store the list in varName.
  3947. pipe [readVar writeVar]
  3948. Create a pipe either setting readVar and writeVar to the read and write
  3949. fileIds, or return a two-element list of the same.
  3950. read_file [-nonewline] fileName
  3951. Read entire contents of fileName optionally discarding the last newline
  3952. character.
  3953. read_file fileName numBytes
  3954. Read at least numBytes characters from fileName.
  3955. select readFileIds [writeFileIds] [exceptFileIds] [float]
  3956. Wait float seconds (default forever) using the select(2) system call for zero
  3957. or more files to become ready for reading, writing, or a pending exception
  3958. condition. The list of fileId’s may be empty. An empty list is returned if the
  3959. timeout expired, or a three-element list each element of which is a list of the
  3960. appropriate fileId’s.
  3961. write_file fileName string [string . . . ]
  3962. Write each string as a newline terminated line to fileName.
  3963. 85
  3964. Tcl/Tk Reference Guide
  3965. 44. TclX Network Programming Support
  3966. host_info addresses host
  3967. host_info official_name host
  3968. host_info aliases host
  3969. Query the default nameserver for host (a name or IP number.)
  3970. 45. TclX File Scanning Commands
  3971. File scanning requires a scan context to search ASCII files. A scan context contains
  3972. one or more match statements, each of which associate regular expressions with
  3973. code to be executed when the expressions are matched.
  3974. scancontext create
  3975. Return a new contextHandle.
  3976. scancontext delete contexthandle
  3977. Delete contextHandle.
  3978. scancontext copyfile contexthandle [copyFileId]
  3979. Query or set the copyfile copyFileId for unmatched lines.
  3980. scanfile [-copyfilecopyFileId] contextHandle fileId
  3981. Scan each line (starting from the current file position) from fileId using
  3982. contextHandle. If -copyfileis specified, copyFileId is used for the
  3983. duration of the command to write all lines unmatched by any pattern or the
  3984. default pattern.
  3985. scanmatch [-nocase] contextHandle [regexp] tclCommand
  3986. Associate tclCommand with regexp in contextHandle. If regexp is omitted,
  3987. the default match is associated with tclCommand. When scanning, a match
  3988. is attempted with each regexp (in the order added) and, if successful,
  3989. tclCommand is evaluated. A continue command will terminate scanning for
  3990. the current line, while return terminates the scanmatch command itself.
  3991. The array matchInfois available to tclCommand with keys:
  3992. line The matched line.
  3993. offset The file offset of the first character of the matched line.
  3994. linenum The line number (relative to the first line scanned) of the
  3995. matched line.
  3996. context The current context handle.
  3997. handle The fileId for the file being scanned.
  3998. copyHandle The fileId specified by -copyfile.
  3999. submatchN Nth parenthesized sub-expression of the regexp.
  4000. subindexN List of starting and ending indices for the Nth parenthesized
  4001. sub-expression of the regexp.
  4002. 46. TclX Math Commands
  4003. The following math functions operate as procedures taking the same arguments as
  4004. the expr command. The result is returned.
  4005. abs ceil floor log10 sqrt
  4006. acos cos fmod pow tan
  4007. asin cosh hypot round tanh
  4008. atan double int sin
  4009. atan2 exp log sinh
  4010. 86
  4011. Tcl/Tk Reference Guide
  4012. Two additional functions are available:
  4013. max num1 [. . . numN]
  4014. expr max(num1, num2)
  4015. Return numeric maximum.
  4016. min num1 [. . . numN]
  4017. expr min(num1, num2)
  4018. Return numeric minumum.
  4019. random limit
  4020. Return a pseudorandom integer such that 0 ≤ number < limit.
  4021. random seed [integer]
  4022. Seed the random number generator, optionally providing integer seed.
  4023. 47. TclX List Manipulation Commands
  4024. intersect lista listb
  4025. Return the sorted logical intersection of lista and listb.
  4026. intersect3 lista listb
  4027. Return a list of three sorted lists: everything in lista not in listb, the
  4028. intersection of lista and listb, and everything in listb not in lista.
  4029. lassign list varName1 [varName2 . . . ]
  4030. Assign successive elements of list to the specified variables. If list contains
  4031. fewer elements than there are varNames, then the additional variables are set
  4032. to {}. If list contains more elements that there are varNames, then return the
  4033. unassigned elements.
  4034. lcontain list element
  4035. Return 1 if element exists in list, 0 otherwise.
  4036. lempty list
  4037. Return 1 if list is empty, 0 otherwise.
  4038. lmatch [switches] list pattern
  4039. Same as lsearch -all. Return all elements of list matching pattern.
  4040. Switches are:
  4041. -exact string match
  4042. -glob glob pattern match (default)
  4043. -regexp regex match
  4044. lrmdups list
  4045. Same as lsort -unique.
  4046. lvarcat varName string [string . . . ]
  4047. Form a single list by concatenating each string to varName. Return and
  4048. assign the result to varName.
  4049. lvarpop varName [indexExpr] [string]
  4050. Replace or delete (if string not present) element indexExpr (default 0) of list
  4051. stored in varName with string. Return the original value of the element
  4052. replaced. If indexExpr begins with end or len, it is replaced by the index
  4053. of the last element or the length of the list respectively.
  4054. lvarpush varName string [indexExpr]
  4055. Insert string before element indexExpr (default 0) of list stored in varName.
  4056. If indexExpr begins with end or len, it is replaced by the index of the last
  4057. element or the length of the list respectively.
  4058. 87
  4059. Tcl/Tk Reference Guide
  4060. union lista listb
  4061. Return the sorted union (duplicates removed) of lista and listb.
  4062. 48. TclX Keyed Lists
  4063. A keyed list is a list, each element of which is a list containing a key-value pair.
  4064. The key-value pairs are referred to as fields. Fields may contain subfields; ‘.’ is the
  4065. separator character. Subfields are actually fields where the value is another keyed
  4066. list.
  4067. keyldel keylistVar key
  4068. Delete the field key from the keyed list in keylistVar.
  4069. keylget keylistVar [key] [varName]
  4070. Return (or set varName with) the value associated with key from the keyed
  4071. list in keylistVar If varName is specified, return 1 if key was found, 0
  4072. otherwise. If key is omitted, then return a list of all keys in the keyed list
  4073. keyListVar.
  4074. keylkeys keylistVar [key]
  4075. Return a list of all keys (or subfield keys of item key) in the keyed list in
  4076. keylistVar.
  4077. keylset keylistVar key value [key2 value2 . . . ]
  4078. Set element key in the keyed list stored in keylistVar, to value.
  4079. 49. TclX String/Character Commands
  4080. ccollate [-local] string1 string2
  4081. Same as string compare if -localomitted. Otherwise comparison uses
  4082. the current locale. This command will not work with UTF or binary data.
  4083. cconcat [string1] [string2 . . . ]
  4084. Return the concatenation of the arguments.
  4085. cequal string string
  4086. Same as string equal.
  4087. cindex string indexExpr
  4088. Returns the character indexed by the indexExpr from string. If indexExpr
  4089. begins with end or len, it is replaced by the index of the last character or
  4090. the length of the string respectively.
  4091. clength string
  4092. Same as string length.
  4093. crange string firstExpr lastExpr
  4094. Return characters from string indexed by firstExpr through lastExpr. If
  4095. either firstExpr or lastExpr begins with end or len, it is replaced by the
  4096. index of the last character or the length of the string respectively.
  4097. csubstr string firstExpr lengthExpr
  4098. Return lengthExpr characters from string indexed by firstExpr. If either
  4099. firstExpr or lastExpr begins with end or len, it is replaced by the index of
  4100. the last character or the length of the string respectively.
  4101. ctoken stringVar separators
  4102. Return the first string delimitted by separators from the string stored in
  4103. stringVar. Replace the contents of stringVar with the remainder of its
  4104. original value.
  4105. 88
  4106. Tcl/Tk Reference Guide
  4107. ctype [-failindexvarName] class string
  4108. Return 1 if all characters in string are of class, 0 otherwise. If
  4109. -failindexis specified, store the index of the first non-matching
  4110. character in varName. Classes are:
  4111. alnum characters are alphabetic or numeric
  4112. alpha characters are alphabetic
  4113. ascii characters are ASCII
  4114. cntrl characters are control characters
  4115. digit characters are decimal digits
  4116. graph characters are printable but not white-space
  4117. lower characters are lowercase
  4118. space characters are white-space
  4119. print characters are printable
  4120. punct characters are punctuation
  4121. upper characters are uppercase
  4122. xdigit characters are hexadecimal digits
  4123. ctype char number
  4124. Return the Unicode character equivalent to number.
  4125. ctype ord character
  4126. Return the decimal Unicode value of character.
  4127. replicate string integer
  4128. Same as string repeat.
  4129. translit from to string
  4130. Translate characters in string, replacing from characters with the
  4131. corresponding to characters. Both from and to may contain character ranges
  4132. in the form ’X-Y’. This command only works with ascii characters.
  4133. 50. TclX XPG/3 Message Catalog Commands
  4134. catopen [-fail] catName
  4135. catopen [-nofail] catName
  4136. Return catHandle, the result of opening message catalog catName. If
  4137. -fail (default -nofail) is specified, an error occurs if the open fails.
  4138. catgets catHandle setNumber msgNumber defaultMsg
  4139. Retrieve message msgNumber in setNumber from catHandle. If not found,
  4140. return defaultMsg.
  4141. catclose [-fail] catHandle
  4142. catclose [-nofail] catHandle
  4143. Close catHandle. If -fail (default -nofail) is specified, an error occurs
  4144. if the close fails.
  4145. 89
  4146. Tcl/Tk Reference Guide
  4147. 51. Img 1.2.4 Package
  4148.  
  4149. This package adds the pixmap image type, and provides the additional photo
  4150. image types bmp, png, jpeg, tiff, xbm, xpm and window. Package command is:
  4151. package require Img
  4152. The pixmap Image Type
  4153. -datastring
  4154. Specify contents of pixmap in XPM format.
  4155. -filefileName
  4156. Gives name of file whose contents define the pixmap in XPM format.
  4157. Additional photo Image Types
  4158. For the imageName read and imageName write commands, the -formatoption
  4159. is used to provide image type specific options. These options are appended to the
  4160. format string.
  4161. imageName read filename -format”bmp”
  4162. imageName write filename -format”bmp”
  4163. imageName read filename -format”gif [option value]
  4164. -indexn
  4165. Selects a specific image from a multi-image GIF file.
  4166. imageName write filename -format”gif”
  4167. -backgroundcolor
  4168. Usually only valid for the bitmap image type, for GIF it now may be used to
  4169. indicate a transparent color.
  4170. imageName read filename -format”jpeg [option value . . .]
  4171. -fastboolean
  4172. Fast, low-quality processing.
  4173. -grayscaleboolean
  4174. Force incoming image to grayscale
  4175. imageName write filename -format”jpeg [option value . . .]
  4176. -grayscaleboolean
  4177. Create monochrome file.
  4178. -qualityn
  4179. Compression quality (0..100; 595 is useful range). Default is 75.
  4180. -smoothn
  4181. Perform smoothing (1030 is enough for most GIF’s). Default is 0.
  4182. -optimizeboolean
  4183. Optimize Huffman table.
  4184. -progressiveboolean
  4185. Create progressive file.
  4186. imageName read filename -format”png”
  4187. imageName write filename -format”png [option value . . .]
  4188. Each option value is used to write a text chunk such as Author, Title, Description,
  4189. etc.
  4190. 90
  4191. Tcl/Tk Reference Guide
  4192. -backgroundcolor
  4193. Usually only valid for the bitmap image type, for PNG it now may be used
  4194. to indicate a transparent color.
  4195. imageName read filename -format”postscript [option value . . .]
  4196. -zoomx [y]
  4197. Multiply image size by given scale factors. If y is missing, the default is the
  4198. same as x. x and y are allowed to be in floating point format, but they are
  4199. rounded to the nearest practically possible value. For postscript the zoom
  4200. factors should be multiples of 1/72.
  4201. imageName read filename -format”tiff”
  4202. imageName write filename -format”tiff [option value . . .]
  4203. -compressiontype
  4204. May be one of deflate, jpeg, packbits, lzw, or none.
  4205. -byteorderwhich
  4206. May be one of bigendian, littleendian, network,
  4207. smallendianor {}.
  4208. image create photo . . . -format window -data pathname
  4209. Pathname must be an existing window, and must be currently mapped.
  4210. imageName read filename -format”xbm”
  4211. imageName write filename -format”xbm”
  4212. imageName read filename -format”xpm”
  4213. imageName write filename -format”xpm”
  4214. 52. Tcllib 1.4
  4215. The Tcl Standard Library is a collection of Tcl packages that provide useful utility
  4216. functions.
  4217. ::math
  4218. Utility math functions. Package command is:
  4219. package require math
  4220. ::math::cov value value . . .
  4221. Return the coefficient of variation expressed as percent of two or more
  4222. numeric values.
  4223. ::math::fibonacci n
  4224. Return the n’th Fibonacci number.
  4225. ::math::integrate {x0 y0 x1 y1 x2 y2 x3 y3 x4 y4 . . . }
  4226. Return a list containing the area under a curve defined by a set of at least five
  4227. x,y pairs and the error bound.
  4228. ::math::max value . . .
  4229. Return the maximum of one or more numeric values.
  4230. ::math::mean value . . .
  4231. Return the arithmetic mean, or average of one or more numeric values.
  4232. ::math::min value . . .
  4233. Return the minimum of one or more numeric values.
  4234. ::math::prod value . . .
  4235. Return the product of one or more numeric values.
  4236. 91
  4237. Tcl/Tk Reference Guide
  4238. ::math::random [value1 [value2]]
  4239. Return a random number. With no arguments, return a floating point value
  4240. between 0 and 1. With one argument, return an integer between 0 and
  4241. value1. With two arguments, return an integer between value1 and value2.
  4242. ::math::sigma value value . . .
  4243. Return the population standard deviation of two or more numeric values.
  4244. ::math::stats value value . . .
  4245. Return a list containing the mean, standard deviation, and coefficient of
  4246. variation expressed as percent of two or more numeric values.
  4247. ::math::sum value . . .
  4248. Return the sum of one or more numeric values.
  4249. ::profiler
  4250. Provide a simple Tcl source code profiler. It collects only function-level
  4251. information, not the more detailed line-level information. Profiling is initiated via
  4252. the ::profiler::init command. Package command is:
  4253. package require profiler
  4254. ::profiler::init
  4255. Initiate profiling. All procedures created after this command is called will be
  4256. profiled.
  4257. ::profiler::dump pattern
  4258. Dump profiling information for the all functions matching pattern (default
  4259. all.) The result is a list of key/value pairs that maps function names to
  4260. information about that function. The information about each function is in
  4261. turn a list of key/value pairs:
  4262. totalCalls
  4263. The total number of times functionName was called.
  4264. callerDist
  4265. A list of key/value pairs mapping each calling function that called
  4266. functionName to the number of times it called functionName.
  4267. compileTime
  4268. The runtime, in clock clicks, of functionName the first time that it was
  4269. called.
  4270. totalRuntime
  4271. The sum of the runtimes of all calls of functionName.
  4272. averageRuntime
  4273. Average runtime of functionName.
  4274. descendantTime
  4275. Sum of the time spent in descendants of functionName.
  4276. averageDescendantTime
  4277. Average time spent in descendants of functionName.
  4278. ::profiler::print [pattern]
  4279. Print profiling information for all functions matching pattern (default all.)
  4280. ::profiler::reset [pattern]
  4281. Reset profiling information for all functions matching pattern (default all.)
  4282. ::profiler::resume [pattern]
  4283. Resume profiling for all functions matching pattern (default all.)
  4284. ::profiler::sortFunctions key
  4285. Return list of functions sorted by a particular profiling statistic. Values for
  4286. 92
  4287. Tcl/Tk Reference Guide
  4288. key are: calls, exclusiveTime, compileTime,
  4289. nonCompileTime, totalRuntime, avgExclusiveTime, and
  4290. avgRuntime. The result is a list of lists, where each sublist consists of a
  4291. function name and the value of key for that function.
  4292. ::profiler::suspend [pattern]
  4293. Suspend profiling for all functions matching pattern (default all.)
  4294. ::struct::graph
  4295. Create and manipulate directed graph objects. Package command is:
  4296. package require struct
  4297. ::struct::graph graphName
  4298. Create a new graph object with an associated global Tcl command whose
  4299. name is graphName.
  4300. graphName arc append arc [-key key] value
  4301. Append value to current value associated with key (default data) for arc.
  4302. graphName arc delete arc . . .
  4303. Remove the specified arcs from the graph.
  4304. graphName arc exists arc
  4305. Return true if the specified arc exists in the graph.
  4306. graphName arc get arc [-key key]
  4307. Return the value associated with key (default data) for arc.
  4308. graphName arc getall arc
  4309. Return list of all key/value pairs for arc.
  4310. graphName arc insert start end [child]
  4311. Insert an arc named child (or a generated arc name) beginning at the node
  4312. start and ending at end.
  4313. graphName arc keyexists arc [-key key]
  4314. Return true if key (default data) exists for arc.
  4315. graphName arc keys arc
  4316. Return list of all keys for arc.
  4317. graphName arc lappend arc [-key key] value
  4318. Append value (as a list) to current value associated with key (default data)
  4319. for arc.
  4320. graphName arc set arc [-key key] [value]
  4321. Set or get the key (default data) value associated with arc. If value omitted,
  4322. return current value.
  4323. graphName arc source arc
  4324. Return the node that arc begins at.
  4325. graphName arc target arc
  4326. Return the node that arc ends at.
  4327. graphName arc unset arc [-key key]
  4328. Remove a keyed (default data) value from arc.
  4329. graphName arcs [[-key key] [-valuevalue]] [-connection nodelist]
  4330. Return a list of all arcs. The list can be limited to arcs based on the keyed
  4331. values associated with the arc, the nodes that are connected by the arc, or
  4332. both. The -connection restriction may be one of
  4333. -in All arcs whose target is one of nodelist.
  4334. -out Return all arcs whose source is one of nodelist.
  4335. -adj Return all arcs adjacent to at least one of nodelist.
  4336. 93
  4337. Tcl/Tk Reference Guide
  4338. -inner Return all arcs adjacent to two of nodelist.
  4339. -embedding Return all arcs adjacent to exactly one of nodelist.
  4340. graphName destroy
  4341. Destroy the graph.
  4342. graphName get [-key key]
  4343. Return the value associated with key (default data) for the graph.
  4344. graphName getall
  4345. Return the value associated with key (default data) for the graph.
  4346. graphName keyexists [-key key]
  4347. Return true if key (default data) exists for the graph.
  4348. graphName keys
  4349. Return list of all keys for the graph.
  4350. graphName node append node [-key key] value
  4351. Append value to current value associated with key (default data) for node.
  4352. graphName node degree [-in|-out] node
  4353. Return number of (incoming -in or outgoing -out, default all) arcs
  4354. adjacent to node.
  4355. graphName node delete node . . .
  4356. Remove node and all its arcs from the graph.
  4357. graphName node exists node
  4358. Return true if node exists in the graph.
  4359. graphName node get node [-key key]
  4360. Return the value associated with key (default data) for node.
  4361. graphName node getall node
  4362. Return list of all key/value pairs for node.
  4363. graphName node insert [child]
  4364. Insert a node named child (or a generated name) into the graph. The node
  4365. has no arcs connected to it. The value ”” is assigned to key data.
  4366. graphName node keyexists node [-key key]
  4367. Return true if key (default data) exists for node.
  4368. graphName node keys node
  4369. Return list of all keys for node.
  4370. graphName node lappend node [-key key] value
  4371. Append value (as a list) to current value associated with key (default data)
  4372. for node.
  4373. graphName node opposite node arc
  4374. Return the node at the other end of arc, which has to be adjacent to node.
  4375. graphName node set node [-key key] [value]
  4376. Set or get the key (default data) value associated with arc. If value omitted,
  4377. return current value.
  4378. graphName node unset node [-key key]
  4379. Remove a keyed (default data) value from node.
  4380. graphName nodes [[-key key] [-valuevalue]] [-connection nodelist]
  4381. Return a list of all nodes. The list can be limited to nodes based on the keyed
  4382. values associated with the nodes, the nodes that are connected by the nodes,
  4383. or both. The possible -connection restrictions are the same as for method
  4384. arcs.
  4385. graphName set [-key key] [value]
  4386. Set or return one of the keyed values associated with a graph for key (default
  4387. data).
  4388. 94
  4389. Tcl/Tk Reference Guide
  4390. graphName swap node1 node2
  4391. Swap the position of node1 and node2 in the graph.
  4392. graphName unset [-key key]
  4393. Remove a keyed value from the graph. If no key is specified, data is
  4394. assumed.
  4395. graphName walk node [-orderorder] [-type type] [-dir dir] -commandcmd
  4396. Perform a breadth-first or depth-first walk of the graph starting at node going
  4397. in either the direction of outgoing or opposite to the incoming arcs.
  4398. -type bfs breadth-first
  4399. -type dfs depth-first (default)
  4400. -order pre pre-order (default)
  4401. -order post post-order
  4402. -order both both-order
  4403. -dir backward the direction opposite to the incoming arcs
  4404. -dir forward the direction of the outgoing arcs
  4405. As the walk progresses, cmd will be evaluated at each node, with the mode
  4406. (enter or leave) and values graphName and the name of the node
  4407. appended.
  4408. ::struct::queue
  4409. Create and manipulate queue objects.
  4410. ::struct::queue queueName
  4411. Create a new queue object with an associated global Tcl command whose
  4412. name is queueName.
  4413. queueName clear
  4414. Remove all items from the queue.
  4415. queueName destroy
  4416. Destroy the queue.
  4417. queueName get [count]
  4418. Return and remove the front count (default 1) items of the queue. If count is
  4419. 1, the result is a simple string; otherwise it is a list.
  4420. queueName peek [count]
  4421. Return the front count (default 1) items of the queue. If count is 1, the result
  4422. is a simple string; otherwise it is a list.
  4423. queueName put item . . .
  4424. Put item into the queue.
  4425. queueName size
  4426. Return the number of items in the queue.
  4427. ::struct::stack
  4428. Create and manipulate stack objects.
  4429. ::struct::stack stackName
  4430. Create a new stack object with an associated global Tcl command whose
  4431. name is stackName.
  4432. stackName clear
  4433. Remove all items from the stack.
  4434. stackName destroy
  4435. Destroy the stack.
  4436. 95
  4437. Tcl/Tk Reference Guide
  4438. stackName peek [count]
  4439. Return the top count (default 1) items of the stack. If count is 1, the result is
  4440. a simple string; otherwise it is a list.
  4441. stackName pop [count]
  4442. Return and remove the top count (default 1) items of the stack. If count is 1,
  4443. the result is a simple string; otherwise it is a list.
  4444. stackName push item . . .
  4445. Put item onto the stack.
  4446. stackName size
  4447. Return the number of items on the stack.
  4448. ::struct::tree
  4449. Create and manipulate tree objects.
  4450. ::struct::tree treeName
  4451. Create a new tree object with an associated global Tcl command whose
  4452. name is treeName.
  4453. treeName append node [-key key] value
  4454. Appends value to one of the keyed values (default data) associated with
  4455. node.
  4456. treeName children node
  4457. Return a list of the children of node.
  4458. treeName cut node
  4459. Removes node from the tree, but not its children. The children of node are
  4460. made children of the parent of node.
  4461. treeName delete node . . .
  4462. Remove node and all its children from the tree.
  4463. treeName depth node
  4464. Return number of steps from node to the root node.
  4465. treeName destroy
  4466. Destroy the tree.
  4467. treeName exists node
  4468. Return true if node exists in the tree.
  4469. treeName get node [-key key]
  4470. Return value associated with key (default data) for node.
  4471. treeName getall node
  4472. Return list of key/value pairs (suitable for use with array set for node.
  4473. treeName index node
  4474. Returns index of node in its parent’s list of children.
  4475. treeName insert parent index [child . . . ]
  4476. Insert child . . . (default a generated name) in the child list of parent at
  4477. index. If index is end, the new nodes will be added after the current last
  4478. child. If parent is root, it refers to the root of the tree. A new node has the
  4479. value ”” assigned to key data. If child already exist in treeName, it will be
  4480. moved from its original location. Return a list of nodes added.
  4481. treeName isleaf node
  4482. Return true if node is a leaf of the tree.
  4483. treeName keys node
  4484. Return list of keys for node.
  4485. 96
  4486. Tcl/Tk Reference Guide
  4487. treeName keyexists node [-key key]
  4488. Return true if key (default data) exists for node.
  4489. treeName lappend node [-key key] value
  4490. Append value (as a list) to one of the keyed (default data) values of node.
  4491. treeName move parent index node . . .
  4492. Make the node children of parent, inserting them into the parent’s child list
  4493. at index.
  4494. treeName next node
  4495. Return right sibling of node, or the empty string if node was the last child of
  4496. its parent.
  4497. treeName numchildren node
  4498. Return number of immediate children of node.
  4499. treeName parent node
  4500. Return parent of node.
  4501. treeName previous node
  4502. Return left sibling of node, or the empty string if node was the first child of
  4503. its parent.
  4504. treeName set node [-key key] [value]
  4505. Set or get one of the keyed (default data) values of node. If value omitted,
  4506. return current value.
  4507. treeName size [node]
  4508. Return the number of descendants of node (default root.)
  4509. treeName splice parent from [to] [child]
  4510. Insert child (or a generated name) in the child list of parent at from. If parent
  4511. is root, it refers to the root of the tree. The children of parent which are in
  4512. the range of from and to (default end) are made children of child. Return
  4513. child.
  4514. treeName swap node1 node2
  4515. Swap the position of node1 and node2.
  4516. treeName unset node [-key key]
  4517. Remove a keyed (default data) value from node.
  4518. treeName walk node [-orderorder] [-type type] -commandcmd
  4519. Perform a breadth-first or depth-first walk of the tree starting at node.
  4520. -type bfs breadth-first
  4521. -type dfs depth-first (default)
  4522. -order in in-order
  4523. -order pre pre-order (default)
  4524. -order post post-order
  4525. -order both both-order
  4526. As the walk progresses, cmd will be evaluated at each node. Percent
  4527. substitution will be performed on cmd before evaluation. The following
  4528. substitutions are recognized:
  4529. %% Insert the literal % character.
  4530. %t Name of the tree object.
  4531. %n Name of the current node.
  4532. %a Name of the action occuring; one of enter, leave, or visit.
  4533. 97
  4534. Tcl/Tk Reference Guide
  4535. 53. Tktable 2.8 Package
  4536.  
  4537. The Tktable package provides a table widget for Tk. Package command is:
  4538. package require Tktable
  4539. table pathName options . . .
  4540. Create a new Tcl command whose name is pathName, a table widget. The
  4541. pathName of the window is returned.
  4542. Tktable Options
  4543. -anchor -highlightcolor -invertselected
  4544. -background -highlightthickness -justify
  4545. -cursor -insertbackground -relief
  4546. -exportselection -insertborderwidth -state
  4547. -font -insertofftime -takefocus
  4548. -foreground -insertontime -xscrollcommand
  4549. -highlightbackground -insertwidth -yscrollcommand
  4550. -autoclearboolean
  4551. Does the first keypress in a cell delete previous text (default false).
  4552. -bordercursorcursor
  4553. Show cursor (default crosshair) when over borders.
  4554. -borderwidthpixels
  4555. A value or list of values indicating the width of the 3-D border for interior
  4556. table cells. (Abbrev: -bd).
  4557. -browsecommandtclCommand
  4558. Evaluate tclCommand anytime the active cell changes. (Abbrev:
  4559. -browsecmd). Does %-substitution on tclCommand (See Tktable
  4560. Command Substitution below).
  4561. -cacheboolean
  4562. Should (default off) an internal cache of the table contents be kept.
  4563. -colorigininteger
  4564. What column index (default 0) is the left-most column in the table.
  4565. -colsinteger
  4566. Number of columns (default 10) in the table.
  4567. -colseparatorcharacter
  4568. A separator character (default a Tcl list) used when cutting or pasting data in
  4569. a table.
  4570. -colstretchmodemode
  4571. The stretch mode for columns to fill extra allocated window space, one of:
  4572. none Do not (default) stretch columns.
  4573. unset Only stretch columns without a specific width set.
  4574. all Stretch all columns by the same number of pixels.
  4575. last Stretch only the last column.
  4576. fill Adjust columns to fit window (only valid for -rowstretch).
  4577. This mode may be removed in the future.
  4578. -coltagcommandtclCommand
  4579. Evaluate tclCommand colNumber to determine the tag to be used for a given
  4580. column. It should return the tag name, or a null string.
  4581. 98
  4582. Tcl/Tk Reference Guide
  4583. -colwidthwidth
  4584. Default column width (default 10). Interpreted as characters when width is
  4585. positive, otherwise as pixels.
  4586. -commandtclCommand
  4587. If -usecommandis true, evaluate tclCommand to retrieve cell values
  4588. instead of the -variablearray. Does %-substitution on tclCommand (See
  4589. Tktable Command Substitution below).
  4590. -drawmodemode
  4591. The table drawing mode, one of:
  4592. slow Draw with no flashing, but it is slow for larger tables.
  4593. compatible
  4594. Draw directly to the screen (default) using Tk functions.
  4595. fast Draw directly to the screen using X functions. This restricts
  4596. -borderwidthto 0 or 1. It is best for large tables, but can
  4597. flash and is not 100% Tk compatible.
  4598. single As fast, but only single pixel lines are drawn.
  4599. -flashmodeboolean
  4600. Should (default false) cells flash when their value changes.
  4601. -flashtimeinteger
  4602. Time in 1/4 seconds (default 2) for which a cell should flash when its value
  4603. changes.
  4604. -heightinteger
  4605. The desired height in rows. If zero or less, make just large enough to hold all
  4606. the rows. The height can be further limited by -maxheight.
  4607. -invertselectedboolean
  4608. Should (default false) the foreground/background of an item simply be
  4609. swapped rather than merging the sel tag options when the cell is selected.
  4610. -ipadxpixels
  4611. The internal offset X padding (default 0) for text in a cell. Only affects one
  4612. side (depending on -anchor).
  4613. -ipadypixels
  4614. The internal offset Y padding (default 0) for text in a cell. Only affects one
  4615. side (depending on -anchor).
  4616. -maxheightpixels
  4617. The maximum (default 600) height requested by the window.
  4618. -maxwidthpixels
  4619. The maximum (default 800) width requested by the window.
  4620. -multilineboolean
  4621. The default setting for the multiline tag option. Default is true.
  4622. -padxpixels
  4623. The left and right X padding (default 0) for a cell.
  4624. -padypixels
  4625. The top and bottom Y padding (default 0) for a cell.
  4626. -resizeborderstype
  4627. What kind of interactive border resizing to allow, one of row, col, both
  4628. (default) or none.
  4629. -rowheightheight
  4630. Default row height (default 1). Interpreted as lines when height is positive,
  4631. otherwise as pixels.
  4632. 99
  4633. Tcl/Tk Reference Guide
  4634. -roworigininteger
  4635. What row index (default 0) is the top-most row in the table.
  4636. -rowsinteger
  4637. Number of rows (default 10) in the table.
  4638. -rowseparatorcharacter
  4639. A separator character (default a Tcl list) used when cutting or pasting data in
  4640. a table.
  4641. -rowstretchmodemode
  4642. The stretch mode for rows to fill extra allocated window space. Same modes
  4643. as -colstretchmode.
  4644. -rowtagcommandtclCommand
  4645. Evaluate tclCommand rowNumber to determine the tag to be used for a
  4646. given row. It should return the tag name, or a null string.
  4647. -selectioncommandtclCommand
  4648. Evaluate tclCommand when the selection is retrieved (ie: evaluating
  4649. ”selection get”). (Abbrev: -selcmd). Does %-substitution on tclCommand
  4650. (See Tktable Command Substitution below).
  4651. -selectmodestyle
  4652. The style for manipulating the selection. One of single, browse
  4653. (default), multipleor extended.
  4654. -selecttitleboolean
  4655. Should (default false) title cells be allowed in the selection.
  4656. -selecttypemode
  4657. The type of selection for the table, one of row, col, cell (default), or
  4658. both (meaning row and col).
  4659. -sparsearrayboolean
  4660. Should an associated Tcl array be kept as a sparse array (default true).
  4661. -titlecolsinteger
  4662. Number of columns (default 0) to use as a title area.
  4663. -titlerowsinteger
  4664. Number of rows (default 0) to use as a title area.
  4665. -usecommandboolean
  4666. Should the -commandoption be used. Automatically set true if
  4667. -commandis used, but will reset itself falseif the command returns an
  4668. error.
  4669. -validateboolean
  4670. Should validation occur (default false) for the active buffer.
  4671. -validatecommandtclCommand
  4672. Evaluate tclCommand, which must return a boolean, to validate the input
  4673. into the active cell. If it returns false then the addition is rejected and will not
  4674. occur. (Abbrev: -vcmd). Does %-substitution on tclCommand (See Tktable
  4675. Command Substitution below).
  4676. -variablevarName
  4677. Attach global array variable varName to the table. Keys are row,colfor
  4678. cells, or activefor the value of the active cell buffer.
  4679. -widthinteger
  4680. The desired width in columns. If zero or less, make just large enough to hold
  4681. all the columns. The width can be further limited by -maxwidth.
  4682. -wrapinteger
  4683. The default wrap value for tags. Defaults to false.
  4684. 100
  4685. Tcl/Tk Reference Guide
  4686. Tktable Indices
  4687. row,col, active, anchor, bottomright, end, origin, topleft, @x,y
  4688. Tktable Tag Options
  4689. -anchor -font -justify
  4690. -background -foreground -relief
  4691. -borderwidth -image -state
  4692. -multilineboolean Should text be displayed with newlines on multiple lines.
  4693. -showtextboolean Should the text be shown over an image.
  4694. -wrapboolean Should characters wrap in a cell that is not wide enough.
  4695. Builtin Tag Names: active, flash, sel, title
  4696. Tktable Embedded Window Options
  4697. -background -padx -relief
  4698. -borderwidth -pady
  4699. -stickysticky Stickiness of the window inside the cell, as defined by
  4700. the grid command.
  4701. -windowpathName Name of a window to display.
  4702. Tktable Command Substitution
  4703. Substitution is performed on the tclCommand:
  4704. -selectioncommand -command -browsecommand -validatecommand
  4705. %c maximum number
  4706. of columns in any
  4707. row
  4708. column
  4709. %C equivalent to %r,%c
  4710. %i number of cells 0 for get, 1
  4711. for set
  4712. current cursor position
  4713. %r number of rows row
  4714. %s default value of selection
  4715. empty
  4716. for get,
  4717. current
  4718. value for
  4719. set
  4720. index of last active
  4721. cell
  4722. current value
  4723. %S undefined undefined index of the new
  4724. active cell
  4725. potential new value
  4726. %W window pathname
  4727. Tktable Commands
  4728. table activate index
  4729. Sets the active cell to index.
  4730. table bbox first [last]
  4731. Return a list {x y width height }, the bounding box for first [last].
  4732. table border mark x y [row|column]
  4733. Record x y and the row and/or column border under that point, if any. If row
  4734. or columnis omitted, return a tuple of both border indices (an empty item
  4735. means no border). Otherwise, just the specified item is returned.
  4736. 101
  4737. Tcl/Tk Reference Guide
  4738. table border dragto x y
  4739. Compute the difference between x y and x y of the last border mark
  4740. command. Adjust the previously marked border by the difference.
  4741. table cget option
  4742. General Tk widget cget command.
  4743. table clear cache [first [last]]
  4744. Clears all or specified section of the cache.
  4745. table clear sizes [first [last]]
  4746. Clears all or the specified row and column areas of specific height/width
  4747. dimensions.
  4748. table clear tags [first [last]]
  4749. Clears all or the specified area of all row, column and cell tags.
  4750. table clear all [first [last]]
  4751. Performs all of the above clear functions on all or the specified area.
  4752. table configure [option [value [option value . . . ]]]
  4753. General Tk widget configure command.
  4754. table curselection [value]
  4755. Query the sorted indices of the currently selected cells, or set all the selected
  4756. cells to the given value.
  4757. table curvalue [value]
  4758. Query or set the value of the cell being edited (indexed by active).
  4759. table delete active index1 [index2]
  4760. Delete the character after index1, or from index1 to index2 of the active
  4761. cell. An index is a number, insertor end.
  4762. table delete cols [switches [--]] col [count]
  4763. Delete count (default 1) columns starting at (and including) col. If count is
  4764. negative, delete columns to the left, otherwise to the right. Switches are:
  4765. -holddimensions
  4766. Do not adjust the table column dimension (empty
  4767. columns may appear).
  4768. -holdselection
  4769. Maintain the selection on the absolute cells values.
  4770. Default is to clear the selection.
  4771. -holdtags Do not move tags or adjust widths.
  4772. -holdwindows Do not move embedded windows.
  4773. -keeptitles Do not change title area cells.
  4774. table delete rows [switches [--]] row [count]
  4775. Delete count (default 1) rows starting at (and including) row. If count is
  4776. negative delete rows going up, otherwise going down. Switches are the same
  4777. as for column deletion.
  4778. table get first [last]
  4779. Return a list of values of the cells specified by first and last.
  4780. table height
  4781. Return list describing all rows for which a height has been set.
  4782. table height row
  4783. Return height of row in characters (positive number) or pixels (negative).
  4784. table height row value row value . . .
  4785. Set each row to height value in lines (positive number) or pixels (negative).
  4786. If value is default, then row uses the default height as specified by
  4787. -rowheight.
  4788. 102
  4789. Tcl/Tk Reference Guide
  4790. table hidden
  4791. Returns all hidden cells (those cells covered by a spanning cell).
  4792. table hidden index
  4793. Return the spanning cell covering index, if any.
  4794. table hidden index index . . .
  4795. Return 1 if all indices are hidden cells, 0 otherwise.
  4796. table icursor [arg]
  4797. Query or set the location of the insertion cursor in the active cell. Arg is one
  4798. of: 0 (before the first character), insert(current insertion point) or end
  4799. (end of the text).
  4800. table index index [row|col]
  4801. Return cell coordinate corresponding to index in the form row,col. If row or
  4802. col is specified, then return only that portion.
  4803. table insert active index string
  4804. Insert string at index (one of number, insertor end) in the active cell.
  4805. table insert cols [switches [--]] col [count]
  4806. Inserts count (default 1) columns starting at col. If count is negative, insert
  4807. before col, otherwise insert after. Switches are the same as for column
  4808. deletion.
  4809. table insert rows [switches [--]] row [count]
  4810. Inserts count (default 1) rows starting at row. If count is negative, insert
  4811. above row, otherwise insert below. Switches are the same as for column
  4812. deletion.
  4813. table reread
  4814. Reread old contents of the cell back into the editing buffer.
  4815. table scan args
  4816. See Tk Widget Scroll Commands.
  4817. table see index
  4818. Adjust the view in window so cell at index is visible.
  4819. table selection anchor index
  4820. Set selection anchor to cell index.
  4821. table selection clear first [last]
  4822. Clear any selection of the cells between first and last. If first is all, remove
  4823. selection from all cells.
  4824. table selection includes index
  4825. Return 1 if the cell at index is currently selected, 0 if not.
  4826. table selection set first [last]
  4827. Select all of the cells between first and last.
  4828. table set index [value [index value . . . ]]
  4829. Sets the cells at index to the associated value.
  4830. table set col index [valueList [index valueList . . . ]]
  4831. Set cells at index and subsequent rows to each value in the associated
  4832. valueList.
  4833. table set row index [valueList [index valueList . . . ]]
  4834. Set cells at index and subsequent columns to each value in the associated
  4835. valueList.
  4836. table spans
  4837. Return list {index span . . . }of all known spans.
  4838. table spans index
  4839. Return the span at index, if any.
  4840. 103
  4841. Tcl/Tk Reference Guide
  4842. table spans index rows,cols [index rows,cols . . . ]
  4843. Set span beginning at index for the specified number of rows,cols. A span of
  4844. 0,0 unsets any span on that cell.
  4845. table tag cell tagName
  4846. Return list of cells that use tagName.
  4847. table tag cell tagName index . . .
  4848. Apply tagName to the specified cells. If tagName is {}, reset the cells to the
  4849. default tag.
  4850. table tag cget tagName option
  4851. Return current value of option for tag tagName.
  4852. table tag col tagName
  4853. Return list of columns that use tagName.
  4854. table tag col tagName [col . . . ]
  4855. Apply tagName to the specified columns. If tagName is {}, reset the
  4856. columns to the default tag.
  4857. table tag configure tagName [option [value [option value . . . ]]]
  4858. Modifies tag-specific options for the tag tagName.
  4859. table tag delete tagName
  4860. Delete tagName.
  4861. table tag exists tagName
  4862. Return 1 if tagName exists, 0 otherwise.
  4863. table tag includes tagName index
  4864. Return 1 if index has tag tagName, 0 otherwise.
  4865. table tag lower tagName [belowThis]
  4866. Change priority of tag tagName so it is just below tag belowThis.
  4867. table tag names [pattern]
  4868. Returns a list of the names of all defined tags matching glob pattern (default
  4869. *).
  4870. table tag raise tagName [aboveThis]
  4871. Change priority of tag tagName so it is just above tag aboveThis.
  4872. table tag row tagName
  4873. Return list of rows that use tagName.
  4874. table tag row tagName row . . .
  4875. Apply tagName to the specified rows. If tagName is {}, reset the rows to the
  4876. default tag.
  4877. table validate index
  4878. Force an evaluation via the -validatecommandon cell at index.
  4879. table width
  4880. Return list describing all columns for which a width has been set.
  4881. table width col
  4882. Return width of col in characters (positive number) or pixels (negative).
  4883. table width col value col value . . .
  4884. Set each col to width value in lines (positive number) or pixels (negative). If
  4885. value is default, then col uses the default width as specified by
  4886. -colwidth.
  4887. table window cget index option
  4888. Return current value of option for window at index.
  4889. table window configure index [option [value [option value . . . ]]]
  4890. Modifies embedded window-specific options for the cell at index.
  4891. 104
  4892. Tcl/Tk Reference Guide
  4893. table window delete index . . .
  4894. Delete embedded window from the table and delete the window.
  4895. table window move indexFrom indexTo
  4896. Move embedded window from indexFrom to indexTo. If a window already
  4897. exists in cell indexTo, it will be deleted.
  4898. table window names [pattern]
  4899. Return list of all cells containing embedded windows matching glob pattern
  4900. (default *).
  4901. table xview|yview args
  4902. See Tk Widget Scroll Commands.
  4903. 54. Vu 2.1.0 Package
  4904.  
  4905. This package implements Tk bargraph, piechart and dial widgets, and adds
  4906. stripchart and barchart canvas item types. Package command is:
  4907. package require vu
  4908. Bargraph Widget
  4909. vu::bargraph pathName options . . .
  4910. Create a new Tcl command whose name is pathName, a bargraph widget.
  4911. The pathName of the window is returned.
  4912. Bargraph Options
  4913. -background -font -highlightthickness
  4914. -borderwidth -highlightbackground -orient
  4915. -cursor -highlightcolor -relief
  4916. -alabels { {position string useTick } . . . }
  4917. Place string and/or a tick (if useTick is true¿ at an arbitrarily position along
  4918. the top or left length of the bar.
  4919. -alabfontfont
  4920. The font for -alabelsstring.
  4921. -fg color
  4922. -barcolorcolor
  4923. Color (default red) for the bargraph bar.
  4924. -basebaseVal
  4925. The base (default 0) of the bar. fromVal ≤ baseVal ≤ toVal.
  4926. -blabelsLabelList
  4927. Like -alabels, but for the right or bottom side of the bar.
  4928. -barbackgroundcolor
  4929. Background color for the bar region.
  4930. -barborderwidthunits
  4931. Width in pixels (default 2) of a bar border.
  4932. -blabfontfont
  4933. The font for -blabelsstring.
  4934. -digitsinteger
  4935. Maximum digits (default 6) after the decimal point for floating-point values.
  4936. 105
  4937. Tcl/Tk Reference Guide
  4938. -fromfromVal
  4939. Value (default 0) displayed at bottom (or left) of a bargraph. If
  4940. fromVal > toVal, the bargraph will grow backwards.
  4941. -lengthunits
  4942. -heightunits
  4943. Total height in pixels (default 100) of a bar.
  4944. -labelstring
  4945. Use string as a label (placed on top) for the bargraph.
  4946. -mode mode
  4947. For mode bargraph, the bar grows from baseVal to the current value. For
  4948. slider, a fixed-width slider travels along the bar with its center point
  4949. indicating the current value.
  4950. -padxunits
  4951. The text elements of a bargraph are held together by glue (default 2 pixels)
  4952. that controls their relative positions with regard to one another and to the
  4953. central bar. The -padxoption loosens the glue and makes the elements
  4954. expand from each other horizontally.
  4955. -padyunits
  4956. Like -padx, but controls the vertical glue.
  4957. -showrangeboolean
  4958. If true (default), fromVal and toVal are labeled at the appropriate ends of the
  4959. bar.
  4960. -showvalueboolean
  4961. If true (default), the current value is labeled near the left or bottom end of
  4962. the bar.
  4963. -sliderlengthunits
  4964. In slidermode, the length (default 10) in pixels of the slider.
  4965. -textcolorcolor
  4966. Color for rendering text.
  4967. -tickcolorcolor
  4968. Color (default blue) for ticks.
  4969. -tickintervalnumber
  4970. The interval (default 20.0) between successive ticks. Zero indicates no ticks.
  4971. -ticklengthunits
  4972. Length in pixels (default 4) of a tick mark.
  4973. -to toVal
  4974. Value (default 100) displayed at top (or right) of a bargraph. If
  4975. fromVal > toVal, the bargraph will grow backwards.
  4976. -widthunits
  4977. Width in pixels (default 20) of a bar.
  4978. Bargraph Commands
  4979. bargraph cget option
  4980. General Tk widget option retrieval command.
  4981. bargraph configure [option1 value1 option2 . . . ]
  4982. General Tk widget configuration command.
  4983. bargraph get
  4984. Return the current value of the bargraph.
  4985. bargraph set [value]
  4986. Set the bar to height represented by value.
  4987. 106
  4988. Tcl/Tk Reference Guide
  4989. Dial Widget
  4990. vu::dial pathName options . . .
  4991. Create a new Tcl command whose name is pathName, a dial widget. The
  4992. pathName of the window is returned.
  4993. Dial Options
  4994. -activebackground -highlightbackground -repeatdelay
  4995. -background -highlightcolor -repeatinterval
  4996. -borderwidth -highlightthickness -state
  4997. -cursor -orient -takefocus
  4998. -font -relief -variable
  4999. -foreground
  5000. -beginangleinteger
  5001. Angle (degrees) at which the scale of the dial will start. Zero is at top and the
  5002. angle increases clockwise. To start the scale at the left, use a negative value.
  5003. -bigincrementinteger
  5004. Size of the large increments. If 0 (default) use 1/10 the range of the dial.
  5005. -commandtclProcName
  5006. Call tclProcname with the value of the dial when it changes.
  5007. -constrainvalueboolean
  5008. If true, the value is constrained between the -fromand -to values and
  5009. -resolution. If false (default), only the displayed value is constrained.
  5010. -dialborderwidthunits
  5011. Width (default 3) for the inner dial border width.
  5012. -dialcolorcolor
  5013. Color (default -background) for the inner dial.
  5014. -dialreliefrelief
  5015. The relief (default raised) for the inner dial.
  5016. -digitsinteger
  5017. Significant digits to retain when converting the value of the dial to a string.
  5018. If zero, use the smallest value that guarantees that every possible dial
  5019. position prints as a different string.
  5020. -endangleinteger
  5021. Angle (in degrees) at which the scale will end.
  5022. -fromfloat
  5023. Value corresponding to the counterclockwise-most end of the dial.
  5024. -labelstring
  5025. Use string as the label (placed on top) for the dial.
  5026. -minortickintervalfloat
  5027. The spacing between minor tick marks (those without a numerical value or
  5028. tag.) If 0 (default), no minor tick marks will displayed.
  5029. -modetype
  5030. One of circle(default), or elipse.
  5031. -needlecolorcolor
  5032. Color of the needle.
  5033. -needletypetype
  5034. One of arc, line (default), or triangle.
  5035. 107
  5036. Tcl/Tk Reference Guide
  5037. -pad units
  5038. The elements of a dial are held together by glue (default 2 pixels) that
  5039. controls their relative positions with regard to one another and to the central
  5040. dial. The -pad option loosens the glue and makes the elements expand
  5041. from each other.
  5042. -radiusunits
  5043. Desired radius of the central dial.
  5044. -resolutionfloat
  5045. The resolution (default 1.0) for the dial. If greater than zero then the value,
  5046. tick marks and endpoints will be rounded to an even multiple of float,
  5047. otherwise no rounding occurs.
  5048. -showtagswhich
  5049. Which tags to display at normal tick marks: value (default), label,
  5050. both, or none.
  5051. -showvalueboolean
  5052. If true, display the current value.
  5053. -tickcolorcolor
  5054. Color for the ticks.
  5055. -tickintervalfloat
  5056. The spacing between major tick marks (those with a numeric value or tag.)
  5057. If zero, no tick marks are displayed.
  5058. -tickwidthunits
  5059. Width of the line that ticks are displayed with. The default 0, means a simple
  5060. line.
  5061. -to float
  5062. Value corresponding to the clockwise-most end of the dial. The value may
  5063. be either less than or greater than -from.
  5064. Dial Commands
  5065. dial cget option
  5066. General Tk widget option retrieval command.
  5067. dial configure [option1 value1 option2 . . . ]
  5068. General Tk widget configuration command.
  5069. dial coords [value]
  5070. Return a list {x y}, the coordinates of the point represented by value (default
  5071. current value) along the radius of the dial.
  5072. dial get [x y]
  5073. Return the value (default current value) corresponding to pixel coordinates
  5074. x,y.
  5075. dial identify x y
  5076. Indicate what part of the dial lies under coordinates x,y:
  5077. dial x,y over the dial
  5078. left x,y to the left of the dial
  5079. right x,y to the right of the dial
  5080. dial label [-constrain] [value [string [value string . . . ]]]
  5081. Associate string with value (must be a major tick value). With
  5082. -constrain, value will be changed if necessary to a valid tick value.
  5083. With no arguments, all tags will be shown. With one value, only the label (if
  5084. any) for that value will be shown.
  5085. 108
  5086. Tcl/Tk Reference Guide
  5087. dial set [value]
  5088. Query or set the value of the dial.
  5089. Pie Widget
  5090. vu::pie pathName options . . .
  5091. Create a new Tcl command whose name is pathName, a piegraph widget.
  5092. The pathName of the window is returned.
  5093. Pie Options
  5094. -background -foreground -highlightthickness
  5095. -borderwidth -highlightbackground -relief
  5096. -cursor -highlightcolor -takefocus
  5097. -font
  5098. -angleinteger
  5099. Viewing angle in degrees (0
  5100. ◦ ≤ integer ≤ 90
  5101. ). Zero (default) views the pie
  5102. as a flat circle, 90
  5103. as a flat line.
  5104. -labelstring
  5105. Use string as a title.
  5106. -legendstring
  5107. What fields are to be displayed in the legend and in what order. The default
  5108. is kvpl. Field identifiers are:
  5109. [number] K Key box (the colored square)
  5110. [number] V Value (the numerical value)
  5111. [number] P P (the percentage of the whole)
  5112. [number] L Label (the given label of the slice)
  5113. If number is zero, the field is not shown. The default value is -1.
  5114. For K, a positive value means display the slice’s color in a separate box,
  5115. negative means use the slice’s color as background for the whole text.
  5116. For V, P and L, a positive value specifies the maximum field length to
  5117. display, negative means use a field length equal to the longest required for
  5118. that field.
  5119. -origininteger
  5120. Rotation of the pie in degrees clockwise.
  5121. -precisionnumber
  5122. Precision (default 2) at which to display slice and percentage values.
  5123. -padxwidth
  5124. Space (default 2) in screen units to the right the pie.
  5125. -padyheight
  5126. Space (default 2) in screen units on the bottom of the pie.
  5127. -radiusunits
  5128. The radius (default 80) of the pie.
  5129. -shadowunits
  5130. Depth (default 0) of the shadow drawn when -angleis not 0.
  5131. -sliceborderboolean
  5132. If true (default) draw borders around the slices.
  5133. -smallfontfont
  5134. The font used to draw the values of the slices at their edges in the main pie
  5135. area.
  5136. 109
  5137. Tcl/Tk Reference Guide
  5138. Pie Commands
  5139. pie cget option
  5140. General Tk widget option retrieval command.
  5141. pie configure [option1 value1 option2 . . . ]
  5142. General Tk widget configuration command.
  5143. pie delete pattern . . .
  5144. Delete slices that match the given glob pattern.
  5145. pie explode name1 [value1 [name2 value2 . . . ]]
  5146. Set the explode values of one or more slices. If only one name is given, then
  5147. the explode value for that slice is returned.
  5148. pie itemcget name option
  5149. Returns the current value of the configuration option given by option for
  5150. slice name.
  5151. pie itemconfigure name [option1] [value1 [option2 value2 . . . ]]
  5152. Query or modify the item-specific options for the items given by name.
  5153. Options are:
  5154. -foregroundcolor
  5155. Foreground color of the slice.
  5156. -labelstring
  5157. Label (defaults to name) of the slice.
  5158. -valuefloat
  5159. Value of the slice.
  5160. -explodeunits
  5161. Explode value of the slice, how far separated from the main pie to
  5162. display this piece.
  5163. pie lower name [belowThis]
  5164. Lower name slice below belowThis (default the bottom.)
  5165. pie names [pattern . . . ]
  5166. Return the names of the slices, according to glob pattern (default *.)
  5167. pie order name . . .
  5168. Move the named slices, in order, to the top.
  5169. pie raise name [aboveThis]
  5170. Raise name above aboveThis (default the top.)
  5171. pie swap name name
  5172. Swap the named slices.
  5173. pie set name1 [value1 name2 value2 . . . ]
  5174. Set the values of one or more slices. If only name1 is given, then return its
  5175. value.
  5176. pie value
  5177. Return the sum of the slice values.
  5178. Barchart Canvas Item
  5179. A barchart item displays a set of values in a barchart diagram. Scale lines indicate
  5180. the current scale value.
  5181. canvas create barchart x1 y1 x2 y2 [option value . . . ]
  5182. -tagstagList
  5183. -autocolorboolean
  5184. If true, use a built-in 6-color scheme.
  5185. 110
  5186. Tcl/Tk Reference Guide
  5187. -backgroundcolor
  5188. Background color, or transparent if color is the empty string.
  5189. -barlinecolor
  5190. Color (default black) of a line drawn between and on top of each bar. If
  5191. color is empty, no line is drawn.
  5192. -fillcolor
  5193. Use color for the strip. If color is empty, the bar is transparent and a line is
  5194. drawn using -scalelinecolor.
  5195. -outlinecolor
  5196. Use color for the surrounding item frame, or no frame if color is empty.
  5197. -scalelinecolor
  5198. If a bar value is greater than -scalevaluethen scalevalue is increased
  5199. and a scaleline is drawn. If color is empty no scaleline is drawn.
  5200. -scalelinestyleinteger
  5201. The scaleline can be dashed: integer dots, integer empty, . . . . Default is 4.
  5202. -scalevaluefloat
  5203. Maximum Y value (default 100), before a scaleline is drawn.
  5204. -valuesvalueList
  5205. List of values. By default, one value is initially allocated.
  5206. Stripchart Canvas Item
  5207. A stripchart item shows a set of values in a X-Y diagram which is scaled
  5208. automatically. Scale lines indicate the current scale value.
  5209. canvas create stripchart x1 y1 x2 y2 [option value . . . ]
  5210. -tagstagList
  5211. -backgroundcolor
  5212. Background color, or transparent if color is the empty string.
  5213. -fillcolor
  5214. Fill the area under the stripline with color. If color is empty, only a line is
  5215. drawn using -striplinecolor.
  5216. -jumpscrollinteger
  5217. When no more room exists to insert a value, the strip will be moved left by
  5218. integer (default 5) pixels.
  5219. -outlinecolor
  5220. Use color for the surrounding item frame, or no frame if color is empty.
  5221. -scaleline black black
  5222. -scalelinecolor
  5223. If a value is greater than -scalevaluethen scalevalue is increased and a
  5224. scaleline is drawn. If color is empty no scaleline is drawn.
  5225. -scalelinestyleinteger
  5226. The scaleline can be dashed: integer dots, integer empty, . . . . Default is 4.
  5227. -scalevaluefloat
  5228. Maximum Y value (default 100), before a scaleline is drawn.
  5229. -striplinecolor
  5230. Use color for the stripline, or no stripline if color is empty.
  5231. -valuesvalueList
  5232. List of values to append on the right. A filled stripchart will require a list of
  5233. length X − jumpscroll − 2.
  5234. 111
  5235. Tcl/Tk Reference Guide
  5236. 55. Vim 6.2 if tcl Interface
  5237. The vim (Vi IMproved) editor may be compiled with a Tcl interface. Ex commands
  5238. invoke the Tcl interpreter, which then provides access to vim via commands and
  5239. variables in the ::vimnamespace.
  5240. The Tcl commands exit and catch are replaced by custom versions. The exit
  5241. command terminates the current Tcl script (deleting the Tcl interpreter) and returns
  5242. to vim – use the :tcl command to create a new Tcl interpreter. The catch command
  5243. works as usual except that exit is not caught. A non-zero exit code causes the
  5244. ex-command that invoked the Tcl script to return an error.
  5245. Vim Ex-mode Commands
  5246. :tcl tclCommand . . .
  5247. Create (if necessary) a Tcl interpreter and evaluate tclCommand. Tcl objects
  5248. will persist from one command to the next.
  5249. [range] :tcl <<[endmarker]
  5250. tclScript
  5251. [endmarker]
  5252. Create (if necessary) a Tcl interpreter and evaluate tclScript. The endmarker
  5253. defaults to a dot (.). This form of the :tcl command is mainly useful for
  5254. including tcl code in Vim scripts.
  5255. [range] :tcldo tclCommand
  5256. Evaluate tclCommand for each line in range (default 1,$) setting Tcl global
  5257. variables line and lnum. line may be modified.
  5258. :tclfile file
  5259. Same as :tcl source file.
  5260. ::vim Special Variables and I/O Streams
  5261. ::vim::current
  5262. An array (updated after ::vim::command is called) containing current
  5263. objects available in vim. The elements are:
  5264. buffer The name of the buffer command for the current buffer.
  5265. window The name of the window command for the current window.
  5266. ::vim::lbase
  5267. If it is set to ’1(default), then lines and columns start at 1 within ::vim,
  5268. othewise 0.
  5269. ::vim::range
  5270. An array with three elements, start, begin and end. Each is a line
  5271. number corresponding to the current range. The values of begin and
  5272. start are identical.
  5273. vimout
  5274. Tcl’s stdoutfile ID is mapped to vimoutand any data written to the
  5275. stream is displayed in the vim message area.
  5276. vimerr
  5277. Tcl’s stderrfile ID is mapped to vimerrand any data written to the
  5278. stream is displayed in the vim message area.
  5279. 112
  5280. Tcl/Tk Reference Guide
  5281. ::vim Commands
  5282. Access to vim buffers and windows is via their name similar to way the a window
  5283. path name is used to refer an individual widget when using Tk.
  5284. ::vim::beep
  5285. Honk. Does not return a result.
  5286. ::vim::buffer exists number
  5287. Check if buffer number exists.
  5288. ::vim::buffer number
  5289. Create a command for buffer number returning its name as the result.
  5290. ::vim::buffer list
  5291. Create a command for each buffer number in list returning a list of their
  5292. names as the result.
  5293. Most buffer commands take line numbers as agruments. In addition to a
  5294. number (interpreted based on value of ::vim::lbase), the value can be
  5295. one of top, start, begin, first, bottom, end or last.
  5296. buffer append line string
  5297. Append string after line.
  5298. buffer command [-quiet] cmd
  5299. Execute vim ex-mode command in buffers context. The -quietoption
  5300. suppresses error messages from vim.
  5301. buffer count
  5302. Return number of lines in the buffer.
  5303. buffer delcmd tclCommand
  5304. Registers tclCommand as a deletion callback for the buffer. The command is
  5305. executed (in the global scope) just before the buffer is deleted.
  5306. buffer delete line [line]
  5307. Deletes a single or range of lines from the buffer.
  5308. buffer expr expression
  5309. Evaluates expression using vim’s internal expression evaluator in buffers
  5310. context returning the result as a string.
  5311. buffer get line [line]
  5312. Return a single or range of lines from the buffer.
  5313. buffer insert line string
  5314. Insert string before line.
  5315. buffer last
  5316. Return the number of the last line in the buffer based on value of
  5317. ::vim::lbase.
  5318. buffer mark mark
  5319. Return the position of the mark as string row number columnnumber.
  5320. buffer name
  5321. Return the name of the file in the buffer.
  5322. buffer number
  5323. Return the number of this buffer.
  5324. buffer option option [value]
  5325. Query or set vim option in buffers context.
  5326. buffer set line string
  5327. buffer set line line list
  5328. Replace a single or range of lines in the buffer. If list contains more elements
  5329. than there are lines to replace, they are inserted. If list contains fewer
  5330. elements, the remaining lines are deleted.
  5331. 113
  5332. Tcl/Tk Reference Guide
  5333. buffer windows
  5334. Returning a list of window command names created for each window that
  5335. displays this buffer.
  5336. ::vim::command [-quiet] command
  5337. Execute vim ex-mode command. The -quietoption suppresses error
  5338. messages from vim.
  5339. ::vim::expr expression
  5340. Evaluates expression using vim’s internal expression evaluator returning the
  5341. result as a string.
  5342. ::vim::option option [value]
  5343. Query or set vim option.
  5344. ::vim::window list
  5345. Create a window command for each window returning a list of command
  5346. names as the result.
  5347. window buffer
  5348. Create a command for the windows buffer returning its name as the result.
  5349. window command [-quiet] command
  5350. Execute vim ex-mode command in windows context. The -quietoption
  5351. suppresses error messages from vim.
  5352. window cursor
  5353. Return the current cursor position as string row number columnnumber
  5354. interpreted based on value of ::vim::lbase.
  5355. window cursor row col
  5356. Set the current cursor position interpreted based on value of
  5357. ::vim::lbase.
  5358. window cursor arrayName
  5359. Set cursor position from arrayName elements row and columninterpreted
  5360. based on value of ::vim::lbase.
  5361. window delcmd tclCommand
  5362. Registers tclCommand as a deletion callback for the window. The command
  5363. is executed (in the global scope) just before the window is closed.
  5364. window expr expression
  5365. Evaluates expression using vim’s internal expression evaluator in windows
  5366. context returning the result as a string.
  5367. window height
  5368. window height number
  5369. Query or attempt to set the window’s height. Return the resulting height.
  5370. window optionoption [value]
  5371. Query or set vim option in windows context.
  5372. Vimconsole 1.2 Package
  5373.  
  5374. This package provides an interactive shell in an xterm(1) window for the ::vim Tcl
  5375. interpreter. Package command is:
  5376. :tcl package require Vimconsole
  5377. ::vimconsole::console
  5378. Start the interactive shell. This command is imported into the global
  5379. namespace.
Add Comment
Please, Sign In to add comment