here2share

Tcl/Tk Reference Guide --

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