contents tcl/tk reference guide - cheat sheets · tcl/tk reference guide conventions fixed denotes...
TRANSCRIPT
Tcl/T
kR
eference
Gu
ide
No
tes
Tk/T
clReference
Guide
Revision
8.0.3c
1989,1997
52
Tcl/T
kR
eference
Gu
ide
forT
cl8.0/T
k8.0
Tk/T
clprogramdesigned
andcreated
byJohn
Ousterhout
Reference
guidecontents
written
byPaulR
aines<[email protected]>
JeffT
ranter<[email protected]>
Reference
guideform
atdesignedand
createdby
JohanV
romans
Co
nten
ts
1.B
asicT
clLanguage
Features
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
2
2.T
clSpecialVariables
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
2
3.O
peratorsand
Expressions
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
3
4.R
egularE
xpressions
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
3
5.Pattern
Globbing
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
4
6.C
ontrolStatements
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
4
7.File
Information
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
5
8.T
clInterpreterInform
ation
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
6
9.L
ists
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
7
10.A
rrays
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
8
11.Strings
andB
inaryD
ata
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
8
12.System
Interaction
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
10
13.File
Input/Output
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
11
14.M
ultipleInterpreters
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
13
15.Packages
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
14
16.N
amespaces
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
14
17.O
therT
clCom
mands
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
15
18.G
eneralTk
WidgetInform
ation
:
:
:
:
:
:
:
:
:
:
:
:
:
18
19.T
kSpecialV
ariables
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
20
20.W
idgetScrollCom
mands
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
20
21.T
heC
anvasW
idget
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
21
22.T
heE
ntryW
idget
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
26
23.T
heL
istboxW
idget
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
27
24.T
heM
enuW
idget
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
28
25.T
heTextW
idget
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
30
26.O
therStandard
Widgets
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
33
27.Im
ages
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
38
28.W
indowInform
ation
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
40
29.T
heW
indowM
anager
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
42
30.B
indingand
VirtualE
vents
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
43
31.G
eometry
Managem
ent:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
45
32.Fonts
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
47
33.O
therT
kC
omm
ands
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
47
Rev.8.0.3
Tcl/T
kR
eference
Gu
ide
Co
nventio
ns
fixed
denotesliteraltext.
thism
eansvariable
text,i.e.thingsyou
mustfillin.
wo
rdis
akeyw
ord,i.e.aw
ordw
itha
specialmeaning.
[...]denotes
anoptional
part.
1.Basic
TclL
ang
uag
eF
eatures
;or
newline
statementseparator
n
statementcontinuation
iflastcharacter
inline
#com
ments
outrestofline
(iffirstnon
�
whitespace
character)
var
simple
variable
var(index)
associativearray
variable
var(i,j)
multi-dim
ensionalarray
variable
$var
variablesubstitution
(also${var}xyz
)
[expr1+2]
comm
andsubstitution
ncharbackslash
substitution(see
below)
"hello$a"
quotingw
ithsubstitution
{hello$a}
quotingw
ithno
substitution(deferred
substitution)
The
onlydata
typein
Tclis
astring.H
owever,som
ecom
mands
willinterpret
arguments
asnum
bers/booleanin
which
casethe
formats
areInteger:
1230xff
(hex)0377
(octal).Floating
Point:2.1
3.
6e4
7.91e+16
Boolean:
truefalse01yesno
Tclm
akesthe
following
backslashsubstitutions:
naaudible
alert(0x7)
nspacespace
nbbackspace
(0x8)
nnewline
space
nfform
feed(0xC
)
ndddoctalvalue
(d=0-7)
nnnew
line(0xA
)
nxddhexadecim
alvalue
(d=0-9,a-f)
nrcarriage
return(0xD
)
ncreplace
‘nc’w
ith‘c’
nthorizontal
tab(0x9)
nn
abackslash
nvverticaltab
(0xB)
2.TclS
pecialV
ariables
argc
Num
berof
comm
andline
arguments.
argv
Tcllistof
comm
andline
arguments.
arg0
Nam
eof
scriptorcom
mand
interpreter.
env
Array
where
eachelem
entname
isan
enviroment
variable.
errorCode
Error
codeinform
ationfrom
thelastT
clerror.
errorInfo
Describes
thestack
traceof
thelastT
clerror.
tcl_library
Location
ofstandard
Tcllibraries.
tcl_patchLevel
Currentpatchlevel
ofT
clinterpreter.
tcl_pkgPath
Listof
directoriesto
searchfor
packageloading.
tcl_platform
Array
with
elements
byteOrder
,osVersion
,machine
,platform
,andos
.
2
Tcl/T
kR
eference
Gu
ide
Co
mm
and
Ind
ex
after,15
app
end,8
array,8
bell,47
bg
error,16
bin
ary,8
bin
d,43
bin
dtag
s,44
bitm
ap,38
break,4
butto
n,33
canvas,21
case,4
catch,16
cd,10
checkbu
tton,33
clipb
oard,47
clock,10
close,11
con
cat,7
con
tinu
e,4
destroy,48
entry,26
eof,11
error,16
eval,16
event,44
exec,11
exit,4
expr,16
fblo
cked,11
fcon
fig
ure,11
fcop
y,12
file,5
fileeven
t,12
flu
sh,12
focu
s,48
fon
t,47
for,4
foreach,4
form
at,9
frame,34
gets,12
glo
b,11
glo
bal,16
grab,48
grid,46
histo
ry,16
if,4
imag
e,38
incr,16
info,6
interp,13
join,7
label,34
lapp
end,7
lind
ex,7
linsert,7
list,7
listbox,27
lleng
th,7
load,16
low
er,48
lrang
e,7
lreplace,7
lsearch,7
lsort,7
men
u,28
men
ubu
tton,35
messag
e,35
nam
espace,14
op
en,12
op
tion,48
pack,45
packag
e,14
parray,8
ph
oto,39
pid,11
place,45
pro
c,16
pu
ts,12
pw
d,11
radio
butto
n,35
raise,48
read,12
regexp,9
regsu
b,9
renam
e,17
return,4
scale,36
scan,9
scrollb
ar,37
seek,12
selection,48
send,48
set,17
socket,12
sou
rce,17
split,8
string,9
sub
st,10
switch,4
tell,12
text,30
time,17
tk,48
top
level,38
trace,17
un
kno
wn,17
un
set,17
up
date,17
up
level,17
up
var,17
variable,15
vwait,17
wh
ile,4
win
fo,40
wm
,42
51
Tcl/T
kR
eference
Gu
ide
-type
buttonSetO
neofabortretryignore,ok,okcancel,
retrycancel,yesno
oryesnocancel
.
tk_o
ptio
nM
enu
wvarN
ame
value[value
...]C
reatesoption
menu
with
name
wconsisting
ofthe
givenvalues.T
hecurrent
valueis
storedin
globalvariablevarN
ame.R
eturnsinternal
menu
name.
tk_p
op
up
menu
xy
[entry]Postpopup
menu
sothat
entryis
positionedatrootcoords
xy.
tk_setP
alettecolor
Changes
thecolor
scheme
forT
kso
thedefaultbackground
coloris
colorand
otherdefault
colorsare
computed.
tk_setP
alettenam
ecolor
[name
color...]
Setthedefaultcolor
forthe
named
optionsin
thecolor
scheme
explicitly.Possible
optionsare:
activeBackground
highlightColor
activeForeground
insertBackground
background
selectColor
disabledForeground
selectBackground
foreground
selectForeground
highlightBackground
troughColor
50
Tcl/T
kR
eference
Gu
ide
tcl_precision
Num
berof
significantdigitsto
retainw
henconverting
floating-pointnum
bersto
strings(default12).
tcl_traceCompileL
eveloftracing
infooutputduring
bytecodecom
pilation.
tcl_traceExec
Levelof
tracinginfo
outputduringbytecode
execution.
tcl_version
Currentversion
ofT
clinterpreter.
3.Op
erators
and
Exp
ression
s
The
expr
comm
andrecognizes
thefollow
ingoperators,in
decreasingorder
ofprecedence:
-˜
!unary
minus,bitw
iseN
OT,logicalN
OT
*/
%m
ultiply,divide,remainder
+-
add,subtract<<
>>
bitwise
shiftleft,bitwise
shiftright<
><=
>=
booleancom
parisons==
!=
booleanequals,notequals
&bitw
iseA
ND
^
bitwise
exclusiveO
R|
bitwise
inclusiveO
R&&
logicalAN
D||
logicalOR
x?y:z
ifx!=0
,theny
,elsez
Alloperators
supportintegers.Allsupportfloating
pointexcept˜
,%,<<
,>>
,&,
^
,and
|.B
ooleanoperators
canalso
beused
forstring
operands,inw
hichcase
stringcom
parisonw
illbeused.T
hisw
illoccurif
anyof
theoperands
arenotvalid
numbers.T
he&&
,||
,and?:
operatorshave
“lazyevaluation”,as
inC
.
Possibleoperands
arenum
ericvalues,T
clvariables(w
ith$
),stringsin
doublequotes
orbraces,T
clcomands
inbrackets,and
thefollow
ingm
athfunctions:
abs
ceil
floor
log10
sinh
acos
cos
fmod
pow
sqrt
asin
cosh
hypot
rand
srand
atan
double
int
round
tan
atan2
exp
log
sin
tanh
4.Reg
ular
Exp
ression
s
regex|regex
match
eitherexpression
regex*m
atchzero
orm
oreof
regex
regex+m
atchone
orm
oreof
regex
regex?m
atchzero
orone
ofregex
.any
singlecharacter
exceptnewline
^
match
beginningof
string
$m
atchend
ofstring
ncm
atchcharacter
ceven
ifspecial
[abc]m
atchsetof
characters
[
^
abc]m
atchcharacters
notinset
[a-z]m
atchrange
ofcharacters
[
^
a-z]m
atchcharacters
notinrange
3
Tcl/T
kR
eference
Gu
ide
()
groupexpressions
5.Pattern
Glo
bb
ing
?m
atchany
singlecharacter
*m
atchzero
orm
orecharacters
[abc]m
atchsetof
characters
[a-z]m
atchrange
ofcharacters
ncm
atchcharacter
c
{a,b,...}
match
anyof
stringsa,b,etc.
˜hom
edirectory
(forg
lob
comm
and)
˜userm
atchuser’s
home
directory(for
glo
bcom
mand)
Note:
forthe
glo
bcom
mand,a
“.”atthe
beginningof
afile’s
name
orjustafter
“/”m
ustbem
atchedexplicitly
andall“/”
charactersm
ustbem
atchedexplicitly.
6.Co
ntro
lStatem
ents
break
Abortinnerm
ostcontainingloop
comm
and.
caseO
bsolete,seesw
itch.
con
tinu
eSkipto
thenextiteration
ofinnerm
ostcontaining
loopcom
mand.
exit[returnC
ode]
Terminate
theprocess,returning
returnCode
(aninteger
which
defaultsto
0)to
thesystem
asthe
exitstatus.
for
starttestnextbodyL
oopingcom
mand
where
start,next,andbody
areT
clcomm
andstrings
andtestis
anexpression
stringto
bepassed
toexp
rcom
mand.
foreach
varname
listbodyT
heT
clcomm
andstring
bodyis
evaluatedfor
eachitem
inthe
stringlist
where
thevariable
varname
issetto
theitem
’svalue.
foreach
varlist1list1
[varlist2list2
...]body
Same
asabove,exceptduring
eachiteration
ofthe
loop,eachvariable
invarlistN
issetto
thecurrentvalue
fromlistN
.
ifexpr1[
then
]body1
[elseif
expr2[
then
]body2
...][
[else
]bodyN
]If
expressionstring
expr1evaluates
true,Tclcom
mand
stringbody1
isevaluated.O
therwise
ifexpr2
istrue,body2
isevaluated,and
soon.If
noneof
theexpressions
evaluateto
truethen
bodyNis
evaluated.
return
[-cod
ecode]
[-errorin
foinfo]
[-errorco
de
code][string]
Return
imm
ediatelyfrom
currentprocedurew
ithstring
asreturn
value.
switch
[options]string
{pattern1
body1[
pattern2body2
...]}
The
stringargum
entism
atchedagainsteach
ofthe
patternargum
entsin
order.The
bodyNof
thefirstm
atchfound
isevaluated.If
nom
atchis
foundand
thelastpattern
isthe
keyword
default
,itsbodyN
isevaluated.Possible
optionsare
-exact
,-glob
,and-regexp
.
wh
iletestbody
Evaluates
theT
clcomm
andstring
bodyas
longas
expressionstring
testevaluates
totrue.
4
Tcl/T
kR
eference
Gu
ide
tkwait
variable
varNam
ePause
programuntilglobalvariable
varNam
eis
modified.
tkwait
visibility
window
Pauseprogram
untilw
indow’s
visibilityhas
changed.
tkwait
win
do
ww
indowPause
programuntil
window
isdestroyed.
tk_b
isqu
eSetdefaultcolor
paletteto
oldbisque
scheme.
tk_ch
oo
seCo
lor
[optionvalue
...]Pops
updialog
foruser
tochoose
colorand
returnschoice.O
ptionsare:
-initialcolor
colorM
akesdefault
choicecolor.
-parent
window
Makes
window
parentofdialog.
-title
stringM
akesstring
titleof
dialogw
indow.
tk_d
ialog
topwtitle
textbitmap
defaultstring
[string...]
Popsup
dialogusing
toplevelwindow
topww
itha
buttonfor
eachstring
argument.R
eturnsindex
ofbutton
userpresses,starting
from0
forthe
leftmostbutton.T
heindex
defaultspecifiesthe
defaultbutton.
tk_fo
cusN
extwindow
Returns
thenextw
indowafter
window
infocus
order.
tk_fo
cusP
revw
indowR
eturnsthe
previousw
indowbefore
window
infocus
order.
tk_fo
cusF
ollo
wsM
ou
seC
hangefocus
modelof
applicationso
focusfollow
sthe
mouse
pointer.
tk_g
etOp
enF
ile[option
value...]
Popsup
dialogfor
userto
choosean
existingfilenam
eand
returnschoice.
Options
are:
-defaultextension
extensionString
toappend
tofilenam
eif
noextensions
existson
chosenfilenam
e.
-filetypes
filePatternList
Listof
filepatternelem
entsof
theform
typeNam
e{
extension[extension
...]}[{
macType
...}]
-initialdir
directoryD
isplayfiles
indirectory.
-initialfile
fileNam
eM
akedefaultchoice
fileNam
e.
-parent
window
Makes
window
parentofdialog.
-title
stringM
akesstring
titleof
dialogw
indow.
tk_g
etSaveF
ile[option
value...]
Popsup
dialogfor
userto
choosea
filename
andreturns
choice.Options
aresam
eas
fortk_
getO
pen
File.
tk_m
essageB
ox[option
value...]
Displays
am
essagedialog
andreturns
theunique
symbolic
name
ofbutton
pressedby
user.Options
are:
-default
name
Make
buttonnam
ethe
default.
-message
stringD
isplaystring
asdialog’s
message.
-parent
window
Makes
window
parentofdialog.
-title
stringM
akesstring
titleof
dialogw
indow.
-iconerror|info|question|warning
Adds
specifiedicon
todialog.
49
Tcl/T
kR
eference
Gu
ide
destroy
[window
window
...]D
estroythe
givenw
indows
andtheir
descendents.
focu
s[-force
]w
indowSets
theinputfocus
forw
indow’s
displayto
window
.The-force
optioncause
thefocus
tobe
setevenif
anotherapplication
hasit.
focu
s[-displayof
window
]R
eturnsnam
eof
focusw
indowon
window
’sdisplay.
focu
s-lastfor
window
Returns
thew
indoww
hichm
ostrecentlyhad
focusand
isa
descendentof
window
’stoplevel.
grab
curren
t[window
]R
eturnsnam
eof
currentgrabw
indowon
window
’sdisplay.If
window
isom
itted,returnslistof
allwindow
sgrabbed
byapplication.
grab
releasew
indowR
eleasesgrab
onw
indow.
grab
[set][-global
]w
indowSets
agrab
onw
indoww
hichw
illbelocalunless
-global
specified.
grab
status
window
Returns
none
,local
,orglobal
todescribe
grabstate
ofw
indow.
low
erw
indow[below
This]
Placesw
indowbelow
window
belowT
hisin
stackingorder.
op
tion
add
patternvalue
[priority]A
ddsoption
with
patternvalue
atpriority(0-100)
todatabase.
op
tion
clearC
learsoption
databaseand
reloadsfrom
user’sX
defaults.
op
tion
getw
indownam
eclass
Obtains
optionvalue
forw
indowunder
name
andclass
ifpresent.
op
tion
readfi
lefileN
ame
[priority]R
eadsoptions
fromX
defaults-stylefile
intooption
databaseatpriority.
raisew
indow[aboveT
his]Places
window
abovew
indowaboveT
hisin
stackingorder.
selection
clear[-displayof
window
][-selection
selection]C
learsselection
(defaultPR
IMA
RY
)on
window
’sdisplay.
selection
get[-
displayof
window
][-selection
selection][-type
type]R
etrievesselection
fromw
indow’s
displayusing
representationtype.
selection
han
dle
[-selection
sel][-type
type][-format
fmt]
win
cmd
Arranges
forcm
dto
berun
whenever
seloftype
isow
nedby
win.
selection
ow
n[-displayof
window
][-selection
selection]R
eturnspath
name
ofw
indoww
hichow
nsselection
onw
indow’s
display.
selection
ow
n[-selection
selection][-command
comm
and]w
indowC
ausesw
indowto
become
newow
nerof
selectionand
arrangesfor
comm
andto
berun
when
window
laterloses
theselection.
send
[-displayof
window
][-async
]interp
cmd
[argarg
...]E
valuatecm
dw
ithargs
inthe
Tk
applicationinterp
onw
indow’s
display.If-async
isspecified,the
send
comm
andw
illreturnim
mediately.
tkap
pn
ame
[newN
ame]
Settheinterpreter
name
ofthe
applicationto
newN
ame.
tkscalin
g[-displayof
window
][floatN
umber]
Setscalingfactor
forconversion
between
physicalunitsand
pixelson
window
’sdisplay
where
floatNum
beris
pixelsper
point(1/72inch).
48
Tcl/T
kR
eference
Gu
ide
7.File
Info
rmatio
n
file
atime
fileNam
eT
ime
fileNam
ew
aslastaccessed
asseconds
sinceJan.1,1970.
file
attributes
fileNam
e[option
[value...]
]Q
ueryor
setplatform-specific
attributesof
fileNam
e.Options
arefor
UN
IX:
-group
,-owner
,-permissions
;forW
indows-archive
,-hidden
,-longname
,-readonly
,-shortname
,-system
;andfor
MacO
S:-creator
,-hidden
,-readonly
,-type
.
file
cop
y[-force]
[--]
source[source
...]target
Makes
acopy
ofsource
undernam
etarget.If
multiple
sourcesare
given,targetm
ustbea
directory.Use
-force
tooverw
riteexisting
files.
file
delete
[-force][-
-]fileN
ame
[fileNam
e...]
Rem
ovesgiven
files.Use
-force
torem
ovenon-em
ptydirectories.
file
dirn
ame
fileNam
eR
eturnsalldirectory
pathcom
ponentsof
fileNam
e.
file
executab
lefileN
ame
Returns
1if
fileNam
eis
executableby
user,0otherw
ise.
file
existsfileN
ame
Returns
1if
fileNam
eexists
(anduser
canread
itsdirectory),0
otherwise.
file
extensio
nfileN
ame
Returns
allcharactersin
fileNam
eafter
andincluding
thelastdot.
file
isdirecto
ryfileN
ame
Returns
1if
fileNam
eis
adirectory,0
otherwise.
file
isfile
fileNam
eR
eturns1
iffileN
ame
isa
regularfile,0
otherwise.
file
join
name
[name
...]Joins
filenam
esusing
thecorrectpath
separatorfor
thecurrentplatform
.
file
lstatfileNam
evarN
ame
Same
asfi
lestatexceptuses
thelstatkernelcall.
file
mkd
irdirN
ame
[dirNam
e...]
Creates
givendirectories.
file
mtim
efileN
ame
Tim
efileN
ame
was
lastmodified
asseconds
sinceJan.1,1970.
file
nativen
ame
fileNam
eR
eturnsthe
platform-specific
name
offileN
ame.
file
ow
ned
fileNam
eR
eturns1
iffileN
ame
owned
bythe
currentuser,0otherw
ise.
file
path
type
fileNam
eR
eturnsone
ofabsolute
,relative
,orvolumerelative
.
file
readab
lefileN
ame
Returns
1if
fileNam
eis
readableby
currentuser,0
otherwise.
file
readlin
kfileN
ame
Returns
valueof
symbolic
linkgiven
byfileN
ame.
file
renam
e[-force]
[--]
source[source
...]target
Renam
esfile
sourceto
target.Iftargetis
anexisting
directory,eachsource
fileis
moved
there.The
-force
optionforces
overwriting
ofexisting
files.
file
roo
tnam
efileN
ame
Returns
allthecharacters
infileN
ame
upto
butnotincludinglastdot.
5
Tcl/T
kR
eference
Gu
ide
file
sizefileN
ame
Returns
sizeof
fileNam
ein
bytes.
file
splitfileN
ame
Returns
listwhose
elements
arethe
pathcom
ponentsof
fileNam
e.
file
statfileNam
evarN
ame
Placeresults
ofstatkernelcallon
fileNam
ein
variablevarN
ame
asan
arrayw
ithelem
entsatime
,ctime
,dev
,gid
,ino
,mode
,mtime
,nlink
,size
,type
,anduid
.
file
tailfileNam
eR
eturnallcharacters
infileN
ame
afterlastdirectory
separator.
file
type
fileNam
eR
eturnstype
offileN
ame.Possible
valuesare
file
,directory
,characterSpecial
,blockSpecial
,fifo
,link
,orsocket
.
file
volu
me
Returns
just“/”on
UN
IX,listof
localdriveson
Window
s,andlistof
localand
network
driveson
MacO
S.
file
writab
lefileN
ame
Returns
1if
fileNam
eis
writable
bycurrent
user,0otherw
ise.
8.TclIn
terpreter
Info
rmatio
n
info
args
procNam
eR
eturnslistdescribing
inorder
thenam
esof
arguments
toprocN
ame.
info
bo
dy
procNam
eR
eturnsthe
bodyof
procedureprocN
ame.
info
cmd
cou
nt
Returns
thetotalnum
berof
comm
andsthathave
beeninvoked.
info
com
man
ds
[pattern]R
eturnslistof
Tclcom
mands
(built-insand
procs)m
atchingglob
pattern.Ifno
patternis
given,returnsallcom
mands
incurrentnam
espace.
info
com
plete
comm
andR
eturns1
ifcom
mand
isa
complete
Tclcom
mand,0
otherwise.C
omplete
means
havingno
unclosedquotes,braces,brackets
orarray
elementnam
es
info
defau
ltprocNam
earg
varNam
eR
eturns1
ifprocedure
procNam
ehas
adefault
forargum
entarg
andplaces
thevalue
invariable
varNam
e.Returns
0if
thereis
nodefault.
info
existsvarN
ame
Returns
1if
thevariable
varNam
eexists
inthe
currentcontext,0otherw
ise.
info
glo
bals
[pattern]R
eturnslistof
globalvariablesm
atchingglob
pattern(default
*).
info
ho
stnam
eR
eturnsnam
eof
computer
onw
hichinterpreter
was
invoked.
info
levelR
eturnsthe
stacklevelof
theinvoking
procedure.
info
levelnumber
Returns
name
andargum
entsof
procedureinvoked
atstacklevelnum
ber.
info
library
Returns
name
oflibrary
directoryw
herestandard
Tclscripts
arestored.
info
load
ed[interp]
Returns
listdescribingpackages
loadedinto
interp.
6
Tcl/T
kR
eference
Gu
ide
32.Fo
nts
fon
tactu
alfontDesc
[-displayof
window
][option]
Returns
actualvaluefor
optionused
byfontD
escon
window
’sdisplay.If
optionis
notgiven,thecom
pleteoption/actual
valuelistis
returned.
fon
tco
nfi
gu
refontnam
e[option
[valueoption
value...]]
Query/setfontoptions
forapplication
createdfontfontnam
e.
fon
tcreate
[fontname
[optionvalue
...]]C
reatenew
applicationfontfontnam
ew
ithgiven
fontoptions.
fon
td
eletefontnam
e[fontnam
e...]
Delete
givenapplication
createdfonts.
fon
tfam
ilies[-displayof
window
]R
eturnslistof
knowfontfam
iliesdefined
onw
indow’s
display.
fon
tm
easure
fontDesc
[-displayof
window
]text
Returns
width
inpixels
usedby
textwhen
renderedin
fontDesc
onw
indow.
fon
tm
etricsfontD
esc[-displayof
window
][m
etric]Q
ueryfontm
etricsof
fontDesc
onw
indow’s
displayw
herem
etricm
aybebe
oneof-ascent
,-descent
,-linespace
,or-fixed
.Ifm
etricis
notgiven,the
complete
metric/value
listisreturned.
fon
tn
ames
Returns
listofapplication
createdfonts.
FontD
escription:
1.
fontname
Nam
eof
fontcreatedby
theapplication
with
fon
tcreate.
2.
systemfont
Nam
eof
platform-specific
fontinterpretedby
graphicsserver.
3.
family
[size[style
...]]A
Tcllistw
ithfirstelem
entthenam
eof
afontfam
ily,theoptional
secondelem
entisdesired
size,andadditional
elements
chosenfrom
normal
orbold
,roman
oritalic
,underline
andoverstrike
.
4.
optionvalue
[optionvalue
...]A
Tcllistof
option/valuesas
validfor
fon
tcreate.
FontO
ptions:
-family
name
Fontfamily
(e.g.Courier
,Times
,Helvetica
).
-size
sizeSize
inpoints
(orpixels
ifnegative).
-weight
weight
Either
normal
(default)orbold
.
-slant
slantE
itherroman
(default)oritalic
.
-underline
booleanW
hetheror
notfontisunderlined.
-overstrike
booleanW
hetheror
notfontisoverstriked.
33.Oth
erT
kC
om
man
ds
bell[-
displayof
window
]R
ingthe
Xbellon
window
’sdisplay.
clipb
oard
clear[-displayof
window
]C
laimow
nershipof
clipboardon
window
’sdisplay,clearing
itscontents.
clipb
oard
app
end
[-displayof
win]
[-format
fmt]
[-type
type]data
Append
datato
clipboardon
win’s
display.
47
Tcl/T
kR
eference
Gu
ide
place
forg
etwindow
Unm
anagesw
indow.
place
info
window
Returns
listcontainingcurrentplace
configurationof
window
.
place
slavesw
indowR
eturnslists
ofslaves
inthe
window
master.
The
gridC
omm
and
grid
[con
fig
ure]
slave[slave
...][option
value...]
Setshow
slavew
indows
shouldbe
managed
bygrid
geometry
master.
-column
n-ipady
amount
-row
n-columnspan
n-padx
amount
-rowspan
n-in
other-pady
amount
-sticky
[n][s
][e][w
]-ipadx
amount
grid
bb
oxm
aster[colum
nrow
[column2
row2]]
Returns
boundingbox
inpixels
ofspace
occupiedby
whole
grid(no
args),the
cell(2args),or
areaspanning
between
givencells
(4args).
grid
colu
mn
con
fig
ure
master
columnL
ist[options]Set/query
column
propertiesof
givencolum
nsin
gridm
aster.
-minsize
sizeM
inimum
sizeof
column.
-pad
amount
Paddingto
addto
sidesof
largestslave.
-weight
intR
elativew
eightforapportioning
extraspace.
grid
forg
etslave[slave
...]R
emoves
(andunm
aps)each
slavefrom
gridforgetting
itsconfiguration.
grid
info
slaveR
eturnslistdescribing
configurationstate
ofslave.
grid
locatio
nm
asterx
yR
eturnscolum
nand
rowcontaining
screenunits
xy
inm
aster.Ifx
yis
outsidegrid,-1
isreturned.
grid
pro
pag
atem
aster[boolean]
Set/queryw
hetherm
astertries
toresize
itsancestor
window
sto
fitgrid.
grid
remove
slave[slave
...]R
emoves
(andunm
aps)each
slavefrom
gridrem
embering
itsconfiguration.
grid
row
con
fig
ure
master
rowL
ist[options]Set/query
rowproperties
ofgiven
rows
ingrid
master.Sam
eoptions
asfor
colu
mn
con
fig
ure
butforrow
s.
grid
sizem
asterR
eturnssize
ofgrid
(ascolum
nsrow
s)for
master.
grid
slavesm
aster[-row
row]
[-column
column]
With
nooptions,a
listofallslaves
inm
asteris
returned.Otherw
ise,returnsa
listofslaves
inspecified
rowor
column.
Grid
Relative
Placem
ent
-Increases
columnspan
ofslave
tothe
left.
xL
eavean
empty
column.
^
Extends
therow
spanof
slaveabove.
46
Tcl/T
kR
eference
Gu
ide
info
locals
[pattern]R
eturnslistof
localvariablesm
atchingglob
pattern(default
*).
info
nam
eofexecu
table
Returns
fullpathname
ofbinary
fromw
hichthe
applicationw
asinvoked.
info
patch
levelR
eturnscurrent
patchlevelfor
Tcl.
info
pro
cs[pattern]
Returns
listofT
clproceduresin
currentnamespace
matching
globpattern
(default*
).
info
script
Returns
name
ofT
clscriptcurrentlybeing
evaluated.
info
shared
libexten
sion
Returns
extensionused
byplatform
forshared
objects.
info
tclversion
Returns
versionnum
berof
Tclin
major.m
inorform
.
info
vars[pattern]
Returns
listofcurrently-visible
variablesm
atchingglob
pattern(default
*).
9.Lists
con
cat[argarg
...]R
eturnsconcatenation
ofeach
listargas
asingle
list.
join
list[joinString]R
eturnsstring
createdby
joiningallelem
entsof
listwith
joinString.
lapp
end
varNam
e[value
value...]
Appends
eachvalue
tothe
endof
theliststored
invarN
ame.
lind
exlistindex
Returns
valueof
elementatindex
inlist.
linsertlistindex
element[elem
ent...]R
eturnsnew
listformed
byinserting
givennew
elements
atindexin
list.
list[argarg
...]R
eturnsnew
listformed
byusing
eacharg
asan
element.
lleng
thlist
Returns
number
ofelem
entsin
list.
lrang
elistfirst
lastR
eturnsnew
listfromslice
oflistatindices
firstthroughlastinclusive.
lreplace
listfirstlast[valuevalue
...]R
eturnsnew
listformed
byreplacing
elements
firstthroughlastin
listwith
givenvalues.
lsearch[m
ode]listpattern
Returns
indexof
firstelementin
listthatmatches
pattern(-1
forno
match).
Mode
may
be-exact
,-glob
(default),or-regexp
.
lsort[sw
itches]list
Returns
newlistform
edby
sortinglistaccording
tosw
itches.These
are
-ascii
stringcom
parison(default)
-dictionary
like-ascii
butignorescase
andis
number
smart.
-index
ndxtreats
eachelem
entsas
asub-listand
sortson
thendxth
element
-integer
integercom
parison
7
Tcl/T
kR
eference
Gu
ide
-real
floating-pointcom
parison
-increasing
sortinincreasing
order(default)
-decreasing
sortindecreasing
order
-command
cmd
Use
cmd
which
takestw
oargum
entsand
returnsan
integerless
than,equalto,orgreater
thanzero
splitstring
[splitChars]
Returns
alistform
edby
splittingstring
ateachcharacter
insplitC
hars.
Note:
listindicesstartat0
andthe
word
end
may
beused
toreference
thelast
elementin
thelist.
10.Arrays
arrayanym
ore
arrayNam
esearchId
Returns
1if
anymore
elements
areleftto
beprocessed
inarray
searchsearchId
onarrayN
ame,0
otherwise.
arrayd
on
esearcharrayN
ame
searchIdTerm
inatesthe
arraysearch
searchIdon
arrayNam
e.
arrayexists
arrayNam
eR
eturns1
ifarrayN
ame
isan
arrayvariable,0
otherwise.
arrayg
etarrayNam
eR
eturnsa
listwhere
eachodd
elementis
anelem
entname
andthe
following
evenelem
entitscorresponding
value.
arrayn
ames
arrayNam
e[pattern]
Returns
listofallelem
entnames
inarrayN
ame
thatmatch
globpattern.
arrayn
extelemen
tarrayNam
esearchId
Returns
name
ofnextelem
entinarrayN
ame
forthe
searchsearchId.
arrayset
arrayNam
elist
Setsvalues
ofelem
entsin
arrayNam
efor
listinarray
getform
at.
arraysize
arrayNam
eR
eturnnum
berof
elements
inarrayN
ame.
arraystartsearch
arrayNam
eR
eturnsa
searchid
touse
foran
element-by-elem
entsearch
ofarrayN
ame.
parray
arrayNam
e[pattern]
Printtostandard
outputthenam
esand
valuesof
allelementnam
esin
arrayNam
ethatm
atchglob
pattern.
11.Strin
gs
and
Bin
aryD
ata
app
end
varNam
e[value
value...]
Appends
eachof
thegiven
valuesto
thestring
storedin
varNam
e.
bin
aryfo
rmatform
atString[arg
arg...]
Returns
abinary
stringrepresentation
ofargss
composed
accordingto
formatString,a
sequenceof
zeroor
more
fieldcodes
eachfollow
edby
anoptional
integercount.T
hepossible
fieldcodes
are:
achars
(nullpadding)c
8-bitintf
floatA
chars(space
padding)s
16-bitint(little)d
doubleb
binary(low
-to-high)S
16-bitint(big)x
nullsB
binary(high-to-low
)i
32-bitint(little)X
backspaceh
hex(low
-to-high)I
32-bitint(big)@
absoluteposition
Hhex
(high-to-low)
8
Tcl/T
kR
eference
Gu
ide
-count
number
%c
Expose
-detail
detail%
dEnter,Leave,Focus
-focus
boolean%
fEnter,Leave
-height
size%
hConfigure
-keycode
number
%k
KeyPress,KeyRelease
-keysym
name
%K
KeyPress,KeyRelease
-mode
notify%
mEnter,Leave,Focus
-override
boolean%
oMap,Reparent,Configure
-place
where
%p
Circulate
-root
window
%R
y
-rootx
coord%
X
y
-rooty
coord%
Y
y
-sendevent
boolean%
Eallevents
-serial
number
%#
allevents-state
state%
sallevents
-subwindow
window
%S
y
-time
integer%
t
y,Property
-x
coord%
x
y,
x
-y
coord%
y
y,
x
y
KeyPress,KeyRelease,ButtonPress,ButtonRelease,
Enter,Leave,Motion
x
Expose,Configure,Gravity,Reparent
31.Geo
metry
Man
agem
ent
The
packC
omm
and
pack
[con
fig
ure]
slave[slave
...][options]
Setshow
slavew
indows
shouldbe
managed
bypack
geometry
master.
-after
sibling-in
master
-pady
pixels-anchor
anchor-ipadx
pixels-fillnone|x|y|both
-before
sibling-ipady
pixels-sidetop|bottom|left|right
-expand
boolean-padx
pixels
pack
forg
etslave[slave
...]U
nmanages
thegiven
slavew
indows.
pack
info
slaveR
eturnslistcontaining
currentpackconfiguration
ofw
indowslave.
pack
pro
pag
atem
aster[boolean]
Enables
ordisables
propagationfor
thew
indowm
aster.
pack
slavesm
asterR
eturnslists
ofslaves
inthe
window
master.
The
placeC
omm
and
place
[con
fig
ure]
window
optionvalue
[optionvalue
...]Sets
howgiven
window
sshould
beplaced
insidetheir
master.
-anchor
anchor-relheight
size-rely
location-height
size-relwidth
size-x
location-in
master
-relx
location-y
location-width
size-bordermodeinside|outside|ignore
45
Tcl/T
kR
eference
Gu
ide
bin
dtag
sw
indow[tagL
ist]Sets
thecurrentprecedence
orderof
tagsfor
window
totagL
ist.IftagL
istisan
empty
list,thetags
aresetback
tothe
defaults.
event
add<<
virtual>>
sequence[sequence
...]A
rrangefor
virtualevent<<
virtual>>
tobe
triggeredw
henanyone
ofgiven
sequencesoccur.
event
delete
<<
virtual>>
[sequence...]
Deletes
givensequences
(orallif
nonegiven)
fromlistthattriggers
thevirtualevent
<<
virtual>>
.
event
gen
eratew
indowevent[-
when
when]
[optionvalue
...]G
enerateeventin
window
asif
itcame
fromw
indowsystem
.Possibleoptions
arelisted
inthe
Event
Field
tablebelow
.The-when
optionsets
when
theeventw
illbeprocessed.Possible
valuesfor
when
are:
now
processim
mediately
(default)
tail
placeatend
ofeventqueue
head
placeatbeginning
ofeventqueue
mark
same
ashead
butbehindprevious
generatedevents
event
info
[<<
virtual>>
]R
eturnslistof
sequencesthattrigger
virtualevent<<
virtual>>
(ifnotgiven,
returnslistof
definedvirtualevents).
The
sequenceargum
entisa
listofone
orm
oreeventpatterns.A
neventpattern
may
bea
singleA
SCII
character,astring
ofthe
form<
modifier-m
odifier-type-detail>,or
<<
name>>
(virtualevent).
Modifiers:Any
Triple
Button5,B5
Mod3,M3
Control
Button1,B1
Meta,M
Mod4,M4
Shift
Button2,B2
Mod1,M1
Mod5,M5
Lock
Button3,B3
Mod2,M2
Alt
Double
Button4,B4
Types:Activate
Enter
Motion
ButtonPress,Button
Expose
Leave
ButtonRelease
FocusIn
Map
Circulate
FocusOut
Property
Colormap
Gravity
Reparent
Configure
KeyPress,Key
Unmap
Deactivate
KeyRelease
Visibility
Destroy
Details:
forbuttons,a
number
1-5for
keys,akeysym
(/usr/include/X11/keysym
def)
Tags:
internalw
indow(applies
tojustthatw
indow)
toplevelwindow
(appliesto
allitsinternalw
indows)
window
classnam
e(applies
toallw
idgetsin
class)all
(appliesto
allwindow
s)
Event
Fields:
Generate
Option
Code
Valid
Events
-above
window
%a
Configure
-borderwidth
size%
BConfigure
-button
number
%b
ButtonPress,ButtonRelease
44
Tcl/T
kR
eference
Gu
ide
bin
aryscan
stringform
atStringvarN
ame
[varNam
e...]
Extracts
valuesinto
varNam
e’sfrom
binarystring
accordingto
formatString.R
eturnsthe
number
ofvalues
extracted.Fieldcodes
arethe
same
asfor
bin
aryfo
rmatexceptfor:
achars
(nostripping)
Achars
(stripping)x
skipforw
ard
form
atformatString
[argarg
...]R
eturnsa
formated
stringgenerated
inthe
AN
SIC
sprintf-likem
anner.Placeholders
havethe
form%
[argpos$][flag][w
idth][.prec][h
|l
]charw
hereargpos,w
idth,andprec
areintegers
andpossible
valuesfor
charare:
dsigned
decimal
Xunsigned
HE
XE
float(0E0)
uunsigned
decimal
cintto
charg
autofloat(f
ore)
isigned
decimal
sstring
Gauto
float(for
E)
ounsigned
octalf
float(fixed)%
plain%
xunsigned
hexe
float(0e0)
andpossible
valuesfor
flagare:
-left-justified
0zero
padding#
alternateoutput
+alw
ayssigned
spacespace
padding
regexp
[switches]
expstring
[matchVar]
[subMatchVar
...]R
eturns1
ifthe
regularexpression
expm
atchespartor
allofstring
,0otherw
ise.Ifspecified,m
atchVarw
illbesetto
allthecharacters
inthe
match
andthe
following
subMatchVar’s
willbe
settom
atchedparenthesized
subexpressions.The
-nocase
switch
canbe
specifiedto
ignorecase
inm
atching.The-indices
switch
canbe
specifiedso
thatmatchVar
andsubM
atchVarw
illbesetto
thestartand
endingindices
instring
oftheir
correspondingm
atch.
regsu
b[sw
itches]exp
stringsubSpec
varNam
eR
eplacesthe
firstportionof
stringthatm
atchesthe
regularexpression
expw
ithsubSpec
andplaces
resultsin
varNam
e.Returns
countofnum
berof
replacements
made.T
he-nocase
switch
canbe
specifiedto
ignorecase
inm
atching.The-all
switch
willcause
allmatches
tobe
substitutedfor.
scanstring
formatString
varNam
e[varN
ame
...]E
xtractsvalues
intogiven
variablesusing
AN
SIC
sscanfbehavior.R
eturnsthe
number
ofvalues
extracted.Placeholdershave
theform
%[*
][width]char
where
*is
fordiscard,w
idthis
aninteger
andpossible
valuesfor
charare:
ddecim
ale
floats
string(non-w
hitespace)o
octalf
float[
chars]chars
ingiven
rangex
hexg
float[
^
chars]chars
notingiven
rangec
charto
int
string
com
pare
string1string2
Returns
-1,0,or1,depending
onw
hetherstring1
islexicographically
lessthan,equalto,or
greaterthan
string2.
string
first
string1string2
Return
indexin
string2of
firstoccuranceof
string1(-1
ifnotfound).
string
ind
exstring
charIndexR
eturnsthe
charIndex’thcharacter
instring.
9
Tcl/T
kR
eference
Gu
ide
string
laststring1
string2R
eturnindex
instring2
oflastoccurance
ofstring1
(-1if
notfound).
string
leng
thstring
Returns
thenum
berof
charactersin
string.
string
match
patternstring
Returns
1if
globpattern
matches
string,0otherw
ise.
string
rang
estring
firstlastR
eturnscharacters
fromstring
atindicesfirstthrough
lastinclusive.
string
tolo
wer
stringR
eturnsnew
stringform
edby
convertingallchars
instring
tolow
ercase.
string
tou
pp
erstring
Returns
newstring
formed
byconverting
allcharsin
stringto
uppercase.
string
trimstring
[chars]R
eturnsnew
stringform
edby
removing
fromstring
anyleading
ortrailing
characterspresentin
thesetchars
(defaultsto
whitespace).
string
trimleftstring
[chars]Sam
eas
string
trimfor
leadingcharacters
only.
string
trimrig
htstring
[chars]Sam
eas
string
trimfor
trailingcharacters
only.
string
wo
rden
dstring
indexR
eturnsindex
ofcharacter
justafterlastone
inw
ordatindex
instring.
string
wo
rdstart
stringindex
Returns
indexof
firstcharacterof
word
atindexin
string.
sub
st[-nobackslashes][-nocom
mands]
[-novariables]string
Returns
resultofbackslash,com
mand,and
variablesubstitutions
onstring.
Each
may
beturned
offby
switch.
12.System
Interactio
n
cd[dirN
ame]
Change
working
directoryto
dirNam
e.
clock
clicksR
eturnshi-res
system-dependent
integertim
evalue.
clock
form
atclockVal[-format
string][-gmt
boolean]C
onvertintegerclockValto
human-readable
formatdefined
bystring
which
recognizes(atleast)
thefollow
ingplaceholders:
%%
%%
Hhour
(00–
23)%
Uw
eek(01
–52)
%a
weekday
(abbr)%
hhour
(00–
12)%
ww
eekday(0
–6)
%A
weekday
(full)%
jday
(001–
366)%
xlocale
date%
bm
onth(abbr)
%m
month
(01–
12)%
Xlocale
time
%B
month
(full)%
Mm
inute(00
–59)
%y
year(00
–99)
%c
localedate
&tim
e%
pA
M/PM
%Y
year(full)
%d
day(01
–31)
%S
seconds(00
–59)
%Z
time
zone
The
defaultformatis
”%a%
b%
d%
H:%
M:%
S%
Z%
Y”.
clock
scandateString
[-base
clockVal][-gmt
boolean]C
onvertdateString
toan
integerclock
value.IfdateString
containsa
24hour
time
only,thedate
givenby
clockValisused.
clock
secon
ds
Return
currentdateand
time
assystem
-dependentinteger
value.
10
Tcl/T
kR
eference
Gu
ide
wm
gro
up
window
[pathNam
e]G
ivespath
name
forleader
ofgroup
tow
hichw
indowbelongs.
wm
icon
bitm
apw
indow[bitm
ap]Specifies
abitm
apto
useas
iconim
agew
henw
indowis
iconified.
wm
icon
ifyw
indowA
rrangefor
window
tobe
iconified.
wm
icon
mask
window
[bitmap]
Specifiesa
bitmap
touse
tom
askicon
image
when
window
isiconified.
wm
icon
nam
ew
indow[new
Nam
e]Specifies
name
touse
asa
labelforw
indow’s
icon.
wm
icon
po
sition
window
[xy]
Specifiesposition
onrootw
indowto
placew
indow’s
icon.
wm
icon
win
do
ww
indow[pathN
ame]
Setspath
name
ofw
indowto
useas
theicon
when
window
isiconified.
wm
maxsize
window
[width
height]Specifies
maxim
umsize
window
may
beresized
toin
eachdirection.
wm
min
sizew
indow[w
idthheight]
Specifiesm
inimum
sizew
indowm
aybe
resizedto
ineach
direction.
wm
overridered
irectw
indow[boolean]
Setorunsetthe
override-redirectflag
ofw
indowcom
monly
usedby
window
manager
todeterm
inew
hetherw
indowshould
decorativefram
e.
wm
po
sition
from
window
[program|user
]Indicate
fromw
homthe
window
’scurrentposition
was
requested.
wm
pro
toco
lwindow
[name]
[comm
and]Specify
aT
clcomm
andto
beinvoked
form
essagesof
protocolnam
e.
wm
resizable
window
[widthB
ooleanheightB
oolean]Specifies
whether
window
’sw
idthand/or
heightisresizable.
wm
sizefrom
window
[program|user
]Indicate
fromw
homthe
window
’scurrentsize
was
requested.
wm
statew
indowR
eturnscurrent
stateof
window
:normal
,icon
,iconic
,orwithdrawn
.
wm
titlew
indow[string]
Settitlefor
window
’sdecorative
frame
tostring.
wm
transien
twindow
[master]
Informs
window
manager
thatwindow
isa
transientofthe
window
master.
wm
with
draw
window
Arranges
forw
indowto
bew
ithdrawn
fromthe
screen.
30.Bin
din
gan
dV
irtualE
vents
bin
dtagR
eturnslistof
allsequencesfor
which
abindings
existsfor
tag.
bin
dtag
sequenceR
eturnsthe
scriptboundto
thegiven
sequencefor
tag.
bin
dtag
sequencescript
Binds
scripttothe
givensequence
fortag.If
scriptisthe
empty
string,thebinding
isdeleted.If
thefirstcharacter
ofscriptis
a+
,thenitis
appendedto
thecurrently
associatedscript.
43
Tcl/T
kR
eference
Gu
ide
win
foscreen
wid
thw
indowR
eturnsthe
width
inpixels
ofw
indow’s
screen.
win
foto
plevelw
indowR
eturnsthe
pathname
ofthe
top-levelwindow
containingw
indow.
win
fovisu
alwindow
Returns
thevisualclass
ofw
indow(see
win
foscreenvisu
al).
win
fovisu
alsavailable
window
Returns
alistw
hoseelem
entsdescribe
thevisuals
availablefor
window
’sscreen
includingclass
anddepth..
win
fovro
oth
eigh
twindow
Returns
theheightof
thevirtualrootw
indowassociated
with
window
.
win
fovro
otw
idth
window
Returns
thew
idthof
thevirtualrootw
indowassociated
with
window
.
win
fovro
otx
window
Returns
thex-offsetof
thevirtualrootw
indowassociated
with
window
.
win
fovro
oty
window
Returns
they-offsetof
thevirtualrootw
indowassociated
with
window
.
win
fow
idth
window
Returns
window
’sw
idthin
pixels.
win
fox
window
Returns
x-coordinateof
theupper-left
cornerof
window
inits
parent.
win
foy
window
Returns
y-coordinateof
theupper-left
cornerof
window
inits
parent.
29.Th
eW
ind
ow
Man
ager
wm
aspect
window
[minN
umer
minD
enomm
axNum
erm
axDenom
]Inform
window
manager
ofdesired
aspectratiorange
forw
indow.
wm
client
window
[name]
Storenam
ein
window
’sW
M_
CL
IEN
T_
MA
CH
INE
property.Informs
window
manager
ofclientm
achineon
which
theapplication
isrunning.
wm
colo
rmap
win
do
ws
window
[window
List]
Storew
indowL
istinw
indow’s
WM_
CO
LO
RM
AP_W
IND
OW
Sproperty
which
identifiesthe
internalwindow
sw
ithinw
indoww
ithprivate
colormaps.
wm
com
man
dw
indow[value]
Storevalue
inw
indow’s
WM_
CO
MM
AN
Dproperty.Inform
sw
indowm
anagerof
comm
andused
toinvoke
theapplication.
wm
deico
nify
window
Arrange
forw
indowto
bem
appedon
thescreen.
wm
focu
smo
delw
indow[active|passive
]Specifies
thefocus
modelfor
window
.
wm
frame
window
Returns
theplatform
window
identifierfor
theouterm
ostdecorativefram
econtaining
window
.Ifw
indowhas
none,returnsplatform
idof
window
itself.
wm
geo
metry
window
[newG
eometry]
Changes
geometry
ofw
indowto
newG
eometry.
wm
grid
window
[baseWidth
baseHeight
widthInc
heightInc]Indicates
thatwindow
isto
bem
anagedas
agridded
window
with
thespecified
relationbetw
eengrid
andpixelunits.
42
Tcl/T
kR
eference
Gu
ide
exec[-keepnew
]arg
[arg...]
Execute
subprocessusing
eacharg
asw
ordfor
ashellpipeline
andreturn
resultsw
rittento
standardout,optionally
retainingthe
finalnewline
char.T
hefollow
ingconstructs
canbe
usedto
controlI/Oflow
.
|pipe
(stdout)
|&
pipe(stdoutand
stderr)
<fileN
ame
stdinfrom
file
<@
fileIdstdin
fromopen
file
<<
valuepass
valueto
stdin
>fileN
ame
stdouttofile
2>fileN
ame
stderrto
file
>&
fileNam
estdoutand
stderrto
file
>>
fileNam
eappend
stdouttofile
2>>
fileNam
eappend
stderrto
file
>>&
fileNam
estdoutand
stderrto
file
>@
fileIdstdoutto
openfile
2>@
fileIdstderr
toopen
file
>&
@fileId
stdoutandstderr
toopen
file
&run
inbackground
glo
b[-nocomplain
]pattern
[pattern...]
Returns
listofallfiles
incurrentdirectory
thatmatch
anyof
thegiven
csh-styleglob
patterns,optionallysuppressing
erroron
nom
atch.
pid
[fileId]R
eturnprocess
idof
processpipeline
fileIdif
given,otherwise
returnprocess
idof
interpreterprocess.
pw
dR
eturnsthe
currentworking
directory.
13.File
Inp
ut/O
utp
ut
close
fileIdC
losethe
openfile
channelfileId.
eoffileId
Returns
1if
anend-of-file
hasoccurred
onfileId,0
otherwise.
fblo
ckedfileId
Returns
1if
lastreadfrom
fileIdexhausted
allavailableinput.
fcon
fig
ure
fileId[option
[value]]Sets
andgets
optionsfor
I/Ochannel
fileId.Options
are:
-blocking
booleanW
hetherI/O
canblock
process.
-bufferingfull|line|none
How
tobuffer
output.
-buffersize
byteSizeSize
ofbuffer.
-eofchar
char|{
inChar
outChar}
Setscharacter
toserve
asend-of-file
marker.
-translation
mode
|{
inMode
outMode}
Setshow
totranslate
end-of-linem
arkers.M
odesare
auto
,binary
,cr
,crlf
,andlf
.
Forsocketchannels
(read-onlysettings):
-sockname
Returns
threeelem
entlistwith
address,hostname
andportnum
ber.11
Tcl/T
kR
eference
Gu
ide
-peername
Forclientand
acceptedsockets,three
elementlistof
peersocket.
Forserialdevice
channels:
-mode
baud,parity,data,stopSetbaud
rate,parity,databits,and
stopbits
ofchannel.
fcop
yinId
outId[-size
size][-command
callback]T
ransferdata
tooutId
frominId
untileofor
sizebytes
havebeen
transferred.If-command
isgiven,copy
occursin
backgroundand
runscallback
when
finishedappending
number
ofbytes
copiedand
possibleerror
message
asargum
ents.
fileeven
tfileIdreadable|writable
[script]E
valuatescriptw
henchannel
fileIdbecom
esreadable/w
ritable.
flu
shfileIdFlushes
anyoutputthathas
beenbuffered
forfileId.
gets
fileId[varN
ame]
Read
nextlinefrom
channelfileId,discarding
newline
character.Placescharacters
ofline
invarN
ame
ifgiven,otherw
isereturns
them.
op
enfileN
ame
[access][perm
s]O
pensfilenam
eand
returnsits
channelid.If
anew
fileis
created,itsperm
issionare
settothe
conjuctionof
perms
andthe
processum
ask.The
accessm
aybe
rR
eadonly.File
mustexist.
r+
Read
andw
rite.Filem
ustexist.
wW
riteonly.T
runcateif
exists.
w+
Read
andw
rite.Truncate
ifexists.
aW
riteonly.File
mustexist.A
ccessposition
atend.
a+
Read
andw
rite.Access
positionatend.
pu
ts[-nonewline
][fileId]
stringW
ritestring
tofileId
(defaultstdout
)optionally
omitting
newline
char.
read[-nonewline
]fileId
Read
allremaining
bytesfrom
fileId,optionallydiscarding
lastcharacterif
itis
anew
line.
readfileId
numB
ytesR
eadnum
Bytes
bytesfrom
fileId.
seekfileId
offset[origin]C
hangecurrent
accessposition
onfileId
tooffsetbytes
fromorigin
which
may
bestart
,current
,orend
.
socket[option
...]host
portO
pena
client-sideT
CP
sockettoserver
hostonport.O
ptionsare:
-myaddr
addrSetnetw
orkaddress
ofclient(if
multiple
available).
-myport
portSetconnection
portofclient(if
differentfromserver).
-async
Make
connectionasynchronous.
socket
-server
comm
and[-myaddr
addr]port
Open
serverT
CP
socketon
portinvokingcom
mand
onceconnected
with
threeargum
ents:the
channel,theaddress,and
theportnum
ber.
tellfileIdReturn
currentaccessposition
infileId.
12
Tcl/T
kR
eference
Gu
ide
win
fom
anag
erw
indowR
eturnsthe
name
ofthe
geometry
manager
currentlyresponsible
forw
indow.
win
fon
ame
window
Returns
window
’snam
ew
ithinits
parent,asopposed
toits
fullpathnam
e.
win
fop
arentw
indowR
eturnsthe
pathnam
eof
window
’sparent.
win
fop
athn
ame
[-displayof
window
]id
Returns
thepath
name
ofthe
window
whose
Xidentifier
isid
onw
indow’s
display.
win
fop
oin
terxw
indowR
eturnsm
ousepointer’s
xcoordinate
onw
indow’s
screen.
win
fop
oin
terxyw
indowR
eturnsm
ousepointer’s
xand
ycoordinates
onw
indow’s
screen.
win
fop
oin
teryw
indowR
eturnsm
ousepointer’s
ycoordinate
onw
indow’s
screen.
win
fop
ixelsw
indownum
berR
eturnsthe
number
ofpixels
inw
indowcorresponding
tothe
distancegiven
bynum
ber,roundedto
nearestinteger.
win
foreq
heig
htw
indowR
eturnsa
decimalstring
givingw
indow’s
requestedheight,in
pixels.
win
foreq
wid
thw
indowR
eturnsa
decimalstring
givingw
indow’s
requestedw
idth,inpixels.
win
forg
bw
indowcolor
Returns
alistof
thethree
RG
Bvalues
thatcorrespondto
colorin
window
.
win
foro
otx
window
Returns
thex-coordinate,in
therootw
indowof
thescreen,of
theupper-left
cornerof
window
(includingits
border).
win
foro
oty
window
Returns
they-coordinate,in
therootw
indowof
thescreen,of
theupper-left
cornerof
window
(includingits
border).
win
foserver
window
Returns
serverinform
ationon
window
’sdisplay.
win
foscreen
window
Returns
thenam
eof
thescreen
associatedw
ithw
indow,in
theform
displayNam
e.screenIndex.
win
foscreen
cellsw
indowR
eturnsthe
number
ofcells
inthe
defaultcolorm
apfor
window
’sscreen.
win
foscreen
dep
thw
indowR
eturnsthe
depth(bits
perpixel)
ofw
indow’s
screen.
win
foscreen
heig
htw
indowR
eturnsthe
heightinpixels
ofw
indow’s
screen.
win
foscreen
mm
heig
htw
indowR
eturnsthe
heightinm
illimeters
ofw
indow’s
screen.
win
foscreen
mm
wid
thw
indowR
eturnsthe
width
inm
illimeters
ofw
indow’s
screen.
win
foscreenvisu
alwindow
Returns
thevisualclass
ofw
indow’s
screen.Maybe
oneof:
directcolor
,grayscale
,pseudocolor
,staticcolor
,staticgray
,ortruecolor
.
41
Tcl/T
kR
eference
Gu
ide
-shrink
Willclip
image
socopied
regionis
inbottom
-rightcorner.
-to
xy
Specifiescoords
ofthe
top-leftcorner
inim
ageto
copyinto.
imageN
ame
redith
erR
editherthe
image.
imageN
ame
write
fileNam
e[option
value...]
Writes
image
datafrom
image
intofile
fileNam
e.
-format
format-nam
eSpecifies
image
formatfor
thefile.
-from
x1y1
x2y2
Specifiesa
rectangularregion
ofthe
image
tocopy
from.
28.Win
do
wIn
form
ation
win
foallm
app
edw
indowR
eturns1
ifw
indowand
allitsancestors
arem
apped,0otherw
ise.
win
foato
m[-displayof
window
]nam
eR
eturnsinteger
identifierfor
atomgiven
bynam
eon
window
’sdisplay.
win
foato
mn
ame
[-displayof
window
]id
Returns
textualname
ofatom
givenby
integerid
onw
indow’s
display.
win
focells
window
Returns
number
ofcells
inthe
colormap
forw
indow.
win
foch
ildren
window
Returns
listcontainingpath
names
ofw
indow’s
childrenin
stackingorder.
win
foclass
window
Returns
theclass
name
ofw
indow.
win
foco
lorm
apfu
llwindow
Return
1if
thecolorm
apfor
window
isfull,0
otherwise.
win
foco
ntain
ing
[-displayof
window
]rootX
rootYR
eturnspath
name
ofw
indowcontaining
thepointrootX
rootYon
window
’sdisplay..
win
fod
epth
window
Returns
thedepth
(bitsper
pixel)of
window
.
win
foexists
window
Returns
1if
window
exists,0if
itdoesn’t.
win
fofp
ixelsw
indownum
berR
eturnsfloating-point
valuegiving
thenum
berof
pixelsin
window
correspondingto
thedistance
givenby
number.
win
fog
eom
etryw
indowR
eturnsthe
pixelgeometry
forw
indow,in
theform
widthxheight+
x+y.
win
foh
eigh
twindow
Returns
heightofw
indowin
pixels.
win
foid
window
Returns
ahexadecim
alstringindicating
theplatform
identifierfor
window
.
win
foin
terps
[-displayof
window
]R
eturnsa
listofallT
clinterpretersregistered
onw
indow’s
display.
win
foism
app
edw
indowR
eturns1
ifw
indowis
currentlym
apped,0otherw
ise.
40
Tcl/T
kR
eference
Gu
ide
14.Mu
ltiple
Interp
reters
interp
aliassrcPath
srcCm
dR
eturnslistw
hoseelem
entsare
thetargetC
md
andargs
associatedw
iththe
aliassrcC
md
ininterpreter
srcPath.
interp
aliassrcPath
srcCm
dD
eletesthe
aliassrcC
md
ininterpreter
srcPath.
interp
aliassrcPath
srcCm
dtargetPath
targetCm
d[arg
...]C
reatesan
aliassrcC
md
ininterpreter
srcPathw
hichw
heninvoked
willrun
targetCm
dand
argsin
theinterpreter
targetPath.
interp
aliases[path]
Returns
listofallaliases
definedin
interpreterpath.
interp
create[-safe]
[--]
[path]C
reatesa
slaveinterpreter
(optionallysafe)
named
path.
interp
delete
path[path
...]D
eletesthe
interpreter(s)path
andallits
slaveinterpreters.
interp
evalpatharg
[arg...]
Evalutes
concatenationof
argsas
comm
andin
interpreterpath.
interp
existspath
Returns
1if
interpreterpath
exists,0otherw
ise.
interp
expo
sepath
hiddenCm
d[exposedC
md]
Make
hiddenCm
din
interppath
exposed(optionally
asexposedC
md).
interp
hid
epath
exposedCm
d[hiddenC
md]
Make
exposedCm
din
interppath
hidden(optionally
ashiddenC
md).
interp
hid
den
pathR
eturnslistof
hiddencom
mands
ininterp
path.
interp
invokeh
idd
enpath
[-glo
bal]
hiddenCm
d[arg
...]Invokes
hiddenCm
dw
ithspecified
argsin
interppath
(atthegloballevelif
-glo
balis
given).
interp
issafe[path]
Returns
1if
interpreterpath
issafe,0
otherwise.
interp
marktru
sted[path]
Marks
interppath
astrusted.
interp
share
srcPathfileId
destPathA
rrangesfor
I/Ochannel
fileIdin
interpretersrcPath
tobe
sharedw
ithinterpreter
destPath.
interp
slaves[path]
Returns
listofnam
esof
allslaveinterpreters
ofinterpreter
path.
interp
targetpath
aliasR
eturnsT
cllistdescribingtargetinterpreter
ofalias
ininterpreter
path.
interp
transfer
srcPathfileId
destPathM
ovesI/O
channelfileId
frominterpreter
srcPathto
destPath.
Foreach
slaveinterpreter
created,anew
Tclcom
mand
iscreated
bythe
same
name
inits
master.T
hiscom
mand
hasthe
alias,aliases,eval,expo
se,hid
e,hid
den,
invokeh
idd
en,issafe,andm
arktrusted
subcomm
andslike
interp,butw
ithoutthe
srcPathand
pathargum
ents(they
defaulttothe
slaveitself)
andw
ithoutthetargetPath
argument(itdefaults
tothe
slave’sm
aster).A
safeinterpreter
iscreated
with
thefollow
ingcom
mands
exposed:after
evalin
crlsearch
split
app
end
expr
info
lsort
string
arrayfb
locked
interp
packag
esu
bst
13
Tcl/T
kR
eference
Gu
ide
break
fileeven
tjo
inp
idsw
itchcase
flu
shlap
pen
dp
roc
tellcatch
for
lind
exp
uts
traceclo
ckfo
reachlin
sertread
un
setclo
sefo
rmat
listren
ame
up
date
con
catg
etsllen
gth
return
up
levelco
ntin
ue
glo
bal
low
erscan
up
vareo
fh
istory
lrang
eseek
vwait
error
iflrep
laceset
wh
ile
Asafe
interpreteris
createdw
iththe
following
comm
andshidden:
cdfco
nfi
gu
relo
adp
wd
sou
rceexec
file
op
enso
cketvw
aitexit
glo
b
15.Packag
es
packag
efo
rgetpackage
Rem
oveallinfo
aboutpackagefrom
interpreter.
packag
eifn
eeded
packageversion
[script]Tells
interpreterthatif
versionversion
ofpackage,evaluating
scriptwill
provideit.
packag
en
ames
Returns
listofallpackages
inthe
interpreterthatare
currentlyprovided
orhave
anifn
eeded
scriptavailable.
packag
ep
rovide
package[version]
Tellsinterpreter
thatpackage
versionis
nowprovided.W
ithoutversion,the
currentlyprovided
versionof
packageis
returned.
packag
ereq
uire
[-exact
]package
[version]Tells
interpreterthat
packagem
ustbeprovided.O
nlypackages
with
versionsequalto
orlater
thanversion
(ifprovided)
areacceptable.If
-exact
isspecified,the
exactversionspecified
mustbe
provided.
packag
eu
nkn
ow
n[com
mand]
Specifiesa
lastresortTclcom
mand
toprovide
apackage
which
haveappend
asits
finaltwo
arguments
thedesired
packageand
version.
packag
evco
mp
areversion1
version2R
eturns-1
ifversion1
isearlier
thanversion2,0
ifequal,and
1if
later.
packag
eversio
ns
packageR
eturnslistof
allversionsnum
bersof
packagew
ithan
ifneed
edscript.
packag
evsatisfi
esversion1
version2R
eturns1
ifversion2
scriptsw
illwork
unchangedunder
version1,0otherw
ise.
16.Nam
espaces
nam
espace
child
ren[nam
espace][pattern]
Returns
listofchild
namespaces
belongingto
namespace
(defaultsto
current)w
hichm
atchpattern
(default*).
nam
espace
cod
escript
Returns
newscriptstring
which
when
evaluatedarranges
forscriptto
beevaluated
incurrentnam
espace.Usefulfor
callbacks.
nam
espace
curren
tR
eturnsfully-qualified
name
ofcurrent
namespace.
14
Tcl/T
kR
eference
Gu
ide
-data
stringSpecify
contentsof
bitmap
inX
11bitm
apform
at.
-file
fileNam
eG
ivesnam
eof
filew
hosecontents
definethe
bitmap
inX
11bitm
apform
at.
-foreground
colorSetforeground
colorfor
bitmap.
-maskdata
stringSpecify
contentsof
mask
inX
11bitm
apform
at.
-maskfile
fileNam
eG
ivesnam
eof
filew
hosecontents
definethe
mask
inX
11bitm
apform
at.
The
photoIm
ageT
ype
-data
stringSpecify
contentsof
image
ina
supportedform
at.
-format
formatN
ame
Specifyform
atfordata
specifiedw
iththe
-data
or-file
options.Instandard
Tk,the
GIF/PG
M/PPM
formats
aresupported.
-file
fileNam
eSpecifies
image
datashould
beread
fromfile
fileNam
e.
-height
number
Fixesthe
heightofthe
image
tonum
berpixels.
-palette
paletteSpecSetthe
resolutionof
thecolor
cubeto
beallocated
forim
age.
-width
number
Fixesthe
width
ofthe
image
tonum
berpixels.
imageN
ame
blan
kB
lanksthe
image
sohas
nodata
andis
completely
transparent.
imageN
ame
cop
ysourceIm
age[option
value...]
Copy
aregion
fromsourceIm
ageto
imageN
ame
usinggiven
options.
-from
x1y1
x2y2
Specifiesrectangular
regionof
sourceim
ageto
becopied.
-to
x1y1
x2y2
Specifiesrectangular
regionof
targetimage
tobe
affected.
-shrink
Willclip
targetimage
socopied
regionis
inbottom
-rightcorner.
-zoom
xy
Magnifies
sourceregion
byx
yin
respectivedirection.
-subsample
xy
Reduces
sourceim
ageby
usingonly
everyx
ythpixel.
imageN
ame
getx
yR
eturnsR
GB
valueof
pixelatcoordsx
yas
listofthree
integers.
imageN
ame
pu
tdata[-to
x1y1
x2y2]
Setspixels
valuesfor
theregion
x1y1
x2y2
for2-D
arraydata.
imageN
ame
readfileN
ame
[optionvalue
...]R
eadsim
agedata
fromfile
fileNam
einto
image
usinggiven
options.
-format
format-nam
eSpecifies
image
formatof
file.
-from
x1y1
x2y2
Specifiesa
rectangularregion
ofthe
image
fileto
copyfrom
.
39
Tcl/T
kR
eference
Gu
ide
Toplevel
-borderwidth
-highlightbackground-relief
-cursor
-highlightcolor
-takefocus
-height
-highlightthickness
-width
-background
colorSam
eas
standardbutm
ybe
empty
topreserve
colormap
space.
-class
stringC
lassnam
efor
thew
indowto
beused
byoption
database.
-colormap
colormap
Color
map
touse
forw
indow.M
aybe
thew
ordnew
,pathname
ofother
toplevel,orem
ptyfor
thedefaultcolorm
apof
screen.
-container
booleanW
hethertoplevelis
acontainer
usedto
embed
anotherapplication.
-menu
pathNam
eM
enuw
idgettobe
usedas
am
enubar.
-use
window
IDToplevelshould
beem
beddedinside
window
identifiedby
window
ID(see
win
foid)
which
was
createdas
acontainer.
-screen
screenScreen
onw
hichto
placethe
window
.
-visual
visualSpecifies
visualtouse
forw
indow.
27.Imag
es
imag
ecreate
type[nam
e][options
value...]
Creates
newim
ageof
typew
ithoptions
andreturns
name.
imag
ed
eletenam
eD
eletesthe
image
name.
imag
eh
eigh
tname
Returns
pixelheightofim
agenam
e.
imag
en
ames
Returns
alistof
thenam
esof
allexistingim
ages.
imag
etyp
enam
eR
eturnsthe
typeof
image
name.
imag
etyp
esR
eturnsa
listofvalid
image
types.
imag
ew
idth
name
Returns
pixelwidth
ofim
agenam
e.
When
anim
ageis
created,Tk
createsa
newcom
mand
with
thesam
enam
eas
theim
age.Forallim
agetypes,this
comm
andsupports
thecg
etandco
nfi
gu
rem
ethodsin
thesam
em
anneras
widgets
forchanging
andquerying
configurationoptions.
The
bitmap
Image
Type
-background
colorSetbackground
colorfor
bitmap.
38
Tcl/T
kR
eference
Gu
ide
nam
espace
delete
[namespace
...]E
achgiven
namespace
isdeleted
alongw
iththeir
childnam
espaces,procedures,and
variables.
nam
espace
evalnamespace
arg[arg
...]A
ctivatesnam
espaceand
evaluatesconcatenation
ofargs’s
insideit.
nam
espace
expo
rt[-clear][pattern
...]A
ddsto
exportlistofcurrentnam
espaceallcom
mands
thatmatch
givenpattern’s.If
-clearis
given,theexportlistis
firstemptied.
nam
espace
forg
et[namespace::pattern
...]R
emoves
fromcurrentnam
espaceany
previouslyim
portedcom
mands
fromnam
espacethatm
atchpattern.
nam
espace
imp
ort
[-force][nam
espace::pattern...]
Imports
intocurrentnam
espacecom
mands
matching
patternfrom
namespace.T
he-fo
rceoption
allows
replacingof
existingcom
mands.
nam
espace
insco
pe
namespace
listArg
[arg...]
Activates
namespace
(which
mustalready
exist)and
evaluatesinside
ittheresultof
lappendof
arg’sto
listArg.
nam
espace
orig
incom
mand
Returns
fully-qualifiednam
eof
imported
comm
and.
nam
espace
paren
t[namespace]
Returns
fully-qualifiednam
eof
parentnamespace
ofnam
espace.
nam
espace
qu
alifiers
stringR
eturnsany
leadingnam
espacequalifiers
instring.
nam
espace
tailstringR
eturnsthe
simple
name
(stripsnam
espacequalifiers)
instring.
nam
espace
wh
ich[-co
mm
and|
-variable]
name
Returns
fully-qualifiednam
eof
thecom
mand
(oras
variable,if-variab
legiven)
name
inthe
currentnamespace.W
illlookin
globalnamespace
ifnot
incurrent
namespace.
variable
[name
value...]
name
[value]C
reatesone
orm
orevariables
incurrentnam
espace(if
name
isunqualified)
initializedto
optionallygiven
values.Insidea
procedureand
outsizea
nam
espace
eval,alocalvariable
iscreated
linkedto
thegiven
namespace
variable.
17.Oth
erT
clCo
mm
and
s
afterm
s[arg1
arg2arg3
...]A
rrangefor
comm
and(concat
ofargs)
tobe
runafter
ms
milliseconds
havepassed.W
ithno
args,programw
illsleepfor
ms
milliseconds.R
eturnsthe
idof
theeventhandler
created.
aftercan
celid|arg1
arg2...
Cancelprevious
aftercom
mand
eitherby
comm
andor
theid
returned.
afterid
le[arg1
arg2arg3
...]A
rrangefor
comm
and(concat
ofargs)
tobe
runlater
when
Tk
isidle.
Returns
theid
ofthe
eventhandlercreated.
afterin
fo[id]
Returns
information
oneventhandler
id.With
noid,returns
alistof
allexisting
eventhandlerids.
15
Tcl/T
kR
eference
Gu
ide
auto_
execok
execFile
Returns
fullpathname
ifan
executablefile
bythe
name
execFile
existsin
user’sPA
TH
,empty
stringotherw
ise.
auto_
load
comm
andA
ttempts
toload
definitionfor
cmd
bysearching
$auto_path
and$env(TCLLIBPATH)
fora
tclIndexfile
which
willinform
theinterpreter
where
itcanfind
comm
and’sdefinition.
auto_
mkin
dex
directorypattern
[pattern...]
Generate
atclIndex
filefrom
allfilesin
directorythatm
atchglob
patterns.
auto_
resetD
estroyscached
information
usedby
auto_
execok
andau
to_
load.
bg
error
message
User
definedhandler
forbackground
Tclerrors.D
efaultexistsfor
Tk.
catchscript[varN
ame]
Evaluate
scriptandstore
resultsinto
varNam
e.Ifthere
isan
error,anon-zero
errorcode
isreturned
andan
errorm
essagestored
invarN
ame.
error
message
[info][code]
Interruptcomm
andinterpretation
with
anerror
describedin
message.G
lobalvariables
errorInfo
anderrorCode
willbe
settoinfo
andcode.
evalarg[arg
...]R
eturnsresultof
evaluatingthe
concatenationof
args’sas
aT
clcomm
and.
expr
arg[arg
...]R
eturnsresultof
evaluatingthe
concatenationof
arg’sas
anoperator
expression.SeeO
peratorsfor
more
info.
glo
balvarN
ame
[varNam
e...]
Declares
givenvarN
ame’s
asglobalvariables.
histo
ryad
dcom
mand
[exec
]A
ddscom
mand
tohistory
list,optionallyexecuting
it.
histo
rych
ang
enew
Value[event]
Replaces
valueof
event(defaultcurrent)in
historyw
ithnew
Value.
histo
ryclear
Erase
thehistory
listandreseteventnum
bers.
histo
ryeven
t[event]R
eturnsvalue
ofevent(default
-1)in
history.
histo
ryin
fo[count]
Returns
eventnumber
andcontents
ofthe
lastcountevents.
histo
rykeep
[count]Setnum
berof
eventsto
retainin
historyto
count.
histo
ryn
extidR
eturnsnum
berfor
nexteventtobe
recordedin
history.
histo
ryred
o[event]
Re-evaluates
event(default-1).
incr
varNam
e[increm
ent]Increm
enttheinteger
valuestored
invarN
ame
byincrem
ent(default1).
load
file[pkgN
ame
[interp]]L
oadbinary
codefor
pkgNam
efrom
file(dynam
iclib)
intointerp.
pro
cnam
eargs
bodyC
reatea
newT
clprocedure(or
replaceexisting
one)called
name
where
argsis
alistof
arguments
andbody
Tclcom
mm
andsto
evaluatew
heninvoked.
16
Tcl/T
kR
eference
Gu
ide
-to
number
Arealvalue
correspondingto
therightor
bottomend
ofthe
scale.
-variable
variableN
ame
ofa
globalvariableto
linkto
thescale.
-width
width
Narrow
dimension
ofscale
(notincludingborder).
scaleco
ord
s[value]
Returns
xand
ycoordinates
ofpointcorresponding
tovalue.
scaleg
et[xy]
Ifx
yis
given,returnsscale
valueatthatcoordinate
position.Otherw
ise,scale’s
currentvalueis
returned.
scaleid
entify
xy
Returns
stringindicating
partofscale
atpositionx
y.Maybe
oneof
slider,trough1,trough2
orem
pty.
scaleset
valueC
hangesthe
currentvalueof
scaleto
value.
Scrollbar
-activebackground
-highlightcolor
-relief
-background
-highlightthickness
-repeatdelay
-borderwidth
-jump
-repeatinterval
-cursor
-orient
-takefocus
-highlightbackground
-troughcolor
-activerelief
number
Relief
touse
when
displayingthe
elementthatis
active.
-command
tclCom
mandP
refixPrefix
ofa
Tclcom
mand
toinvoke
tochange
theview
inthe
widget
associatedw
iththe
scrollbar.
-elementborderwidth
width
Width
ofborders
aroundinternal
elements
(arrows
andslider).
-width
width
Narrow
dimension
ofscrollbar
(notincludingborder).
Elem
ents:arrow1,trough1,slider,trough2,arrow2
scrollbaractivate
[element]
Display
elementw
ithactive
attributes.
scrollbard
eltadeltaX
deltaYR
eturnsfractional
positionchange
forslider
movem
entofdeltaX
deltaY.
scrollbarfractio
nx
yR
eturnsa
realnumber
between
0and
1indicating
where
thepointgiven
bypixelcoords
xy
liesin
thetrough
areaof
thescrollbar.
scrollbarg
etR
eturnscurrent
scrollbarsettings
asthe
list{
firstlast}.
scrollbarid
entify
xy
Returns
name
ofelem
entunderpixelcoords
xy.
scrollbarsetfirst
lastD
escribescurrentview
ofassociated
widgetw
herefirstlastare
thepercentage
distancefrom
widget’s
beginningof
thestartand
endof
theview
.
37
Tcl/T
kR
eference
Gu
ide
-selectimage
image
Image
displayedin
indicatorw
henselected.
-value
valueV
aluegiven
tovariable
specifiedw
ith-variable
optionw
henthe
radiobuttonis
selected.
-variable
variableV
ariableto
associatew
ithradiobutton.
radiobuttond
eselectD
eselecttheradiobutton.
radiobuttonfl
ashA
lternateradiobutton
between
activeand
normalcolors.
radiobuttoninvo
keToggle
theselection
stateof
theradiobutton
andinvoke
theT
clcomm
andspecified
with
-command
,ifany.
radiobuttonselect
Selecttheradiobutton.
Scale
-activebackground
-highlightbackground-repeatdelay
-background
-highlightcolor
-repeatinterval
-borderwidth
-highlightthickness
-state
-cursor
-orient
-takefocus
-foreground
-relief
-troughcolor
-font
-bigincrement
number
Arealvalue
touse
forlarge
increments
ofthe
scale.
-command
tclCom
mand
Specifieda
TC
Lcom
mand
toinvoke
when
scale’svalue
ischanged.T
hescale’s
valuew
illbeappended
asan
additionalargum
ent.
-digits
integerA
ninteger
specifyinghow
many
significantdigits
shouldbe
retained.
-from
number
Arealvalue
correspondingto
leftortop
endof
thescale.
-label
stringA
stringto
displayas
labelforthe
scale.
-length
sizeSpecifies
theheight(w
idth)for
vertical(horizontal)scales.
-resolution
number
Realvalue
tow
hichscale’s
valuew
illberounded
toan
evenm
ultipleof.
-showvalue
booleanW
hetheror
notscale’scurrentvalue
shouldbe
displayedin
sidelabel.
-sliderlength
sizeSize
ofthe
slider,measured
alongthe
slider’slong
dimension.
-sliderrelief
reliefSpecify
therelief
usedto
displaythe
slider.
-tickinterval
number
Arealvalue
tospecify
thespacing
between
numericaltick
marks
displayed.
36
Tcl/T
kR
eference
Gu
ide
renam
eoldN
ame
newN
ame
Renam
ecom
mand
oldNam
eso
itisnow
callednew
Nam
e.Ifnew
Nam
eis
theem
ptystring,com
mand
oldNam
eis
deleted.
setvarNam
e[value]
Storevalue
invarN
ame
ifgiven.R
eturnsthe
currentvalueof
varNam
e.
sou
rcefileN
ame
Read
filefileN
ame
andevaluate
itscontents
asa
Tclscript.
time
script[count]C
allinterpretercount(default
1)tim
esto
evaluatescript.R
eturnsstring
ofthe
form“503microsecondsperiteration
”.
tracevariab
levarN
ame
opscom
mand
Arrange
forcom
mand
tobe
evaluatedw
henevervarN
ame
isaccessed
inone
ofthe
ways
specifiedw
ithops.Possbile
valuesare
rfor
read,wfor
written,
ufor
unset,andany
combination
ofthe
three.
tracevd
eletevarN
ame
opscom
mand
Rem
oveany
previoustrace
specifiedw
iththe
givenargum
ents.
tracevin
fovarN
ame
Returns
listdescribingeach
traceon
varNam
e.
un
kno
wn
cmdN
ame
[argarg
...]C
alledw
henthe
Tclinterpreter
encountersan
undefinedcom
mand
name.
un
setvarNam
e[varN
ame
...]R
emoves
thegiven
variablesand
arraysfrom
scope.
up
date
[idletasks
]H
andlepending
events.Ifidletasks
isspecified,only
thoseoperations
normally
deferreduntilthe
idlestate
areprocessed.
up
level[level]arg
[arg...]
Evaluates
concatenationof
arg’sin
thevariable
contextindicatedby
level,an
integerthatgives
thedistance
upthe
callingstack.If
levelispreceded
by“#”,then
itgivesthe
distancedow
nthe
callingstack
fromthe
globallevel.
up
var[level]
otherVarm
yVar[otherVar
myVar
...]M
akesm
yVarin
localscopeequivalent
tootherVar
atcontextlevel(see
up
level)so
theyshare
thesam
estorage
space.
vwaitvarN
ame
Enter
Tcleventloop
untilglobalvariablevarN
ame
ism
odified.
17
Tcl/T
kR
eference
Gu
ide
18.Gen
eralTk
Wid
get
Info
rmatio
n
Allw
idgetarecreated
with
widget
pathname
[option1
value1[
option2...]
]
where
widgetis
theT
clcomm
andcorresponding
tothe
classof
widgetdesired
(eg.bu
tton)
andpathnam
eis
astring
which
willbe
usedto
identifythe
newly
createdw
idget.Ingeneral,a
widgetnam
eis
theconcatenation
ofits
parent’snam
efollow
edby
aperiod
(unlessthe
parentisthe
rootwindow
“ .”)
anda
stringcontaining
noperiods
(eg. .mainframe.btnframe.btn1
).
Widgetconfiguration
optionsm
aybe
passedin
thecreation
comm
and.Options
beginw
itha
“ -”
andare
always
followed
bya
valuestring.A
ftercreation,options
may
bechanged
usingthe
con
fig
ure
widgetcom
mand
pathname
con
fig
ure
option1value1
[option2
...]
andqueried
usingthe
cgetcom
mand
pathname
cgetoption
Some
ofthe
widgetoptions
which
multiple
widgets
supportaredescribed
herefor
brevity.Foroptions
thattakescreen
units,valuesare
inpixels
unlessan
optionalone
lettersuffix
modifier
ispresent—
c(cm
),i(inch),m
(mm
),orp
(points).
-activebackground
colorB
ackgroundcolor
ofw
idgetwhen
itisactive.
-activeborderwidth
width
Width
inscreen
unitsof
widgetborder
when
itisactive.
-activeforeground
colorForeground
colorof
widgetw
henitis
active.
-anchor
anchorPosH
owinform
ationis
positionedinside
widget.V
alidanchorPos
valuesare
n,
ne,e,se,s,sw,w,nw,
andcenter
.
-background
colorB
ackgroundcolor
ofw
idgetinnorm
alstate(A
bbrev:-bg
).
-bitmap
bitmap
Bitm
apto
displayin
thew
idget(error,gray12,gray25,
gray50,gray75,hourglass,info,questhead,
question,warning,@
filename).
-borderwidth
width
Width
inscreen
unitsof
widgetborder
innorm
alstate(A
bbrev:-bd
).
-command
tclCom
mand
Tclcom
mand
torun
when
widgetis
invoked.
-cursor
cursorC
ursorto
displayw
henm
ousepointer
isin
widget.V
alidform
ats:
name
[fgColor
[bgColor]
Nam
eof
cursorfrom
/usr/include/X11/cursorfont.h.
@sourceN
ame
maskN
ame
fgColor
bgColor
Getsource
andm
askbits
fromfiles
sourceNam
eand
maskN
ame.
@sourceN
ame
fgColor
Getsource
bitsfrom
filesourceN
ame
(backgroundtransparent).
-disabledforeground
colorForeground
colorof
widgetw
henitis
disabled.
-exportselection
booleanW
hetheror
notaselection
inthe
widgetshould
alsobe
theX
selection.
18
Tcl/T
kR
eference
Gu
ide
Menubutton
-activebackground
-foreground
-relief
-activeforeground
-height
-state
-anchor
-highlightbackground-takefocus
-background
-highlightcolor
-text
-bitmap
-highlightthickness-textvariable
-borderwidth
-image
-underline
-cursor
-justify
-width
-disabledforeground-padx
-wraplength
-font
-pady
-direction
directionW
hereto
popup
menu
where
directionis
oneofabove
,below
,left
,right
,andflush
.
-indicatoron
booleanIf
truethen
asm
allindicatorw
illbedisplayed
onthe
button’srightside
andthe
defaultmenu
bindingsw
illtreatthisas
anoption
menubutton.
-menu
pathNam
ePathnam
eof
menu
widgetto
postwhen
buttonis
invoked.
Message
-anchor
-highlightbackground-relief
-background
-highlightcolor
-takefocus
-borderwidth
-highlightthickness
-text
-cursor
-justify
-textvariable
-font
-padx
-width
-foreground
-pady
-aspect
integerR
atioof
textwidth
totextheighttim
es100
touse
todisplay
text.
Radiobutton
-activebackground
-font
-pady
-activeforeground
-foreground
-relief
-anchor
-height
-state
-background
-highlightbackground-takefocus
-bitmap
-highlightcolor
-text
-borderwidth
-highlightthickness
-textvariable
-command
-image
-underline
-cursor
-justify
-width
-disabledforeground-padx
-wraplength
-indicatoron
booleanW
hetheror
nottheindicator
shouldbe
drawn.
-selectcolor
colorC
olorused
tofillin
indicatorw
henselected.
35
Tcl/T
kR
eference
Gu
ide
-offvalue
valueV
aluegiven
tovariable
specifiedw
ith-variable
optionw
henthe
checkbuttonis
deselected.
-onvalue
valueV
aluegiven
tovariable
specifiedw
ith-variable
optionw
henthe
checkbuttonis
selected.
-selectcolor
colorC
olorused
tofillin
indicatorw
henselected.
-selectimage
image
Image
displayedin
indicatorw
henselected.
-variable
variableV
ariableto
associatew
ithcheckbutton.
checkbuttond
eselectD
eselectthecheckbutton.
checkbuttonfl
ashA
lternatecheckbutton
between
activeand
normalcolors.
checkbuttoninvo
keToggle
theselection
stateof
thecheckbutton
andinvoke
theT
clcomm
andspecified
with
-command
,ifany.
checkbuttonselect
Selectthecheckbutton.
checkbuttonto
gg
leToggle
theselection
stateof
thecheckbutton.
Fram
e
-borderwidth
-highlightbackground-relief
-cursor
-highlightcolor
-takefocus
-height
-highlightthickness
-width
-background
colorSam
eas
standardexpectitm
aybe
theem
ptystring
topreserve
colormap.
-class
name
Class
name
touse
inquerying
theoption
databaseand
forbindings.
-colormap
colormap
Colorm
apto
usefor
thew
indowif
differentfromparent.
-container
booleanW
hetherthe
frame
willbe
acontainer
toem
bedanother
application.
-visual
visualV
isualinfoto
usefor
thew
indowif
differentfrom
parent.
Label
-anchor
-height
-pady
-background
-highlightbackground-relief
-bitmap
-highlightcolor
-takefocus
-borderwidth
-highlightthickness
-text
-cursor
-image
-textvariable
-font
-justify
-underline
-foreground
-padx
-width
-wraplength
34
Tcl/T
kR
eference
Gu
ide
-font
fontFontto
usew
hendraw
ingtextinside
thew
idget.
-foreground
colorForeground
colorof
widgetin
normalstate
(Abbrev:
-fg
).
-height
width|
textChars
Heightof
widget.U
nitsdepend
onw
idget.
-highlightbackground
colorC
olorof
therectangle
drawn
aroundthe
widgetw
henitdoes
nothavethe
inputfocus.
-highlightcolor
colorC
olorof
therectangle
drawn
aroundthe
widgetw
henithas
theinputfocus.
-highlightthickness
width
Width
inscreen
unitsof
highlightrectangle
drawn
aroundw
idgetwhen
ithas
theinputfocus.
-image
image
Image
todisplay
inthe
widget(see
Images).
-insertbackground
colorC
olorto
useas
backgroundin
thearea
coveredby
theinsertion
cursor.
-insertborderwidth
width
Width
inscreen
unitsof
borderto
drawaround
theinsertion
cursor.
-insertofftime
milliseconds
Tim
ethe
insertioncursor
shouldrem
ain“off”
ineach
blinkcycle.
-insertontime
milliseconds
Tim
ethe
insertioncursor
shouldrem
ain“on”
ineach
blinkcycle.
-insertwidth
width
Width
inscreen
unitsof
theinsertion
cursor.
-jump
booleanW
hetherto
notifyscrollbars
andscales
connectedto
thew
idgettodelay
updatesuntilm
ousebutton
isreleased.
-justifyleft|center|right
How
multiple
linesline
upw
itheach
other.
-orienthorizontal|vertical
Which
orientationw
idgetshoulduse
inlayout.
-padx
width
Extra
spacein
screenunits
torequestfor
thew
idgetinX
-direction.
-pady
heightE
xtraspace
inscreen
unitsto
requestforthe
widgetin
Y-direction.
-reliefflat|groove|raised|ridge|sunken
3-Deffectdesired
forthe
widget’s
border.
-repeatdelay
milliseconds
Tim
ea
buttonor
keym
ustbeheld
down
beforeitbegins
toauto-repeat.
-repeatinterval
milliseconds
Tim
ebetw
eenauto-repeats
onceaction
hasbegun.
-selectbackground
colorB
ackgroundcolor
touse
when
displayingselected
items.
-selectborderwidth
width
Width
inscreen
unitsof
borderto
drawaround
selecteditem
s.
-selectforeground
colorForeground
colorto
usew
hendisplaying
selecteditem
s.
19
Tcl/T
kR
eference
Gu
ide
-setgrid
booleanW
hetherthis
widgetcontrols
theresizing
gridfor
itstoplevelw
indow.
-statenormal|disabled
(|active
forbutton-type
widgets)
Currentstate
ofw
idget.
-takefocus
focusTypeIf0
or1
,signalsthatthe
widgetshould
neveror
always
takethe
focus.Ifem
pty,Tk
decides.Otherw
ise,evaluatesfocusType
asscriptw
iththe
widget
name
appendedas
argument.T
hereturn
valueof
thescriptm
ustbe0
,1or
empty.
-text
stringTextto
bedisplayed
insidethe
widget.
-textvariable
variableV
ariablew
hichcontains
atextstring
tobe
displayedinside
thew
idget.
-troughcolor
colorC
olorto
usefor
therectangular
troughareas
inw
idget.
-underline
indexInteger
indexof
acharacter
tounderline
inthe
widget.
-width
width|
textChars
Width
ofw
idget.Units
dependon
widget.
-wraplength
lengthM
aximum
linelength
inscreen
unitsfor
word-w
rapping.
-xscrollcommand
cmdP
refixPrefix
fora
comm
andused
tocom
municate
with
horizontalscrollbars.
-yscrollcommand
cmdP
refixPrefix
fora
comm
andused
tocom
municate
with
verticalscrollbars.
19.Tk
Sp
ecialVariab
les
tk_library
Directory
containinglibrary
ofstandard
Tk
scripts.
tk_patchLevel
Integerspecifying
currentpatchlevelfor
Tk.
tkPrivArray
containinginform
ationprivate
tostandard
Tk
scripts.
tk_strictMotif
When
non-zero,Tk
triesto
adhereto
Motif
look-and-feelas
closelyas
possible.
tk_version
Currentversion
ofT
kin
major.m
inorform
.
20.Wid
get
Scro
llCo
mm
and
s
The
Canvas,L
istboxand
Textwidgets
supportthefollow
ingscrolling
comm
ands.T
heE
ntryw
idgetsupportsthe
xviewcom
mand
andthe
scancom
mand
with
they
coordinatedropped.
widget scan
mark
xy
Records
xand
yas
widget’s
currentviewanchor.
widgetscan
drag
tox
yShiftthe
viewby
10tim
esthe
differencebetw
eenthe
coordinatesx
andy
andthe
currentviewanchor
coordinates.
20
Tcl/T
kR
eference
Gu
ide
texttagran
ges
tagNam
eR
eturnsa
listdescribingallcharacter
rangestagged
with
tagNam
e.
text tagrem
ovetagN
ame
index1[index2]
Rem
ovetag
tagNam
efor
allcharactersin
rangeindex1
toindex2.
text win
do
wcg
etindexoption
Return
currentvalueof
optionfor
embedded
window
atindex.
text win
do
wco
nfi
gu
reindex
[option[value
[optionvalue
...]]]M
odifiesem
beddedw
indow-specific
optionsfor
thew
indowatindex.
text win
do
wcreate
index[option
value...]
Create
anew
embedded
window
atpositionindex
with
specifiedoptions.
text win
do
wn
ames
Returns
listofnam
esof
allwindow
sem
beddedin
textwidget.
textxview|
yviewargs
SeeW
idgetScrollCom
mands
above.
26.Oth
erS
tand
ardW
idg
ets
Button
-activebackground
-font
-pady
-activeforeground
-foreground
-relief
-anchor
-height
-state
-background
-highlightbackground-takefocus
-bitmap
-highlightcolor
-text
-borderwidth
-highlightthickness
-textvariable
-command
-image
-underline
-cursor
-justify
-width
-disabledforeground-padx
-wraplength
-default
stateSetstate
ofdefaultring,one
ofactive
,normal
,ordisabled
.
buttonfl
ashA
lternatecheckbutton
between
activeand
normalcolors.
buttoninvo
keToggle
theselection
stateof
thecheckbutton
andinvoke
theT
clcomm
andspecified
with
-command
,ifany.
Checkbutton
-activebackground
-font
-pady
-activeforeground
-foreground
-relief
-anchor
-height
-state
-background
-highlightbackground-takefocus
-bitmap
-highlightcolor
-text
-borderwidth
-highlightthickness
-textvariable
-command
-image
-underline
-cursor
-justify
-width
-disabledforeground-padx
-wraplength
-indicatoron
booleanW
hetheror
nottheindicator
shouldbe
drawn.
33
Tcl/T
kR
eference
Gu
ide
textimag
ecreate
index[option
value...]
Create
anew
embedded
image
atpositionindex
with
specifiedoptions.
text imag
en
ames
Returns
listofnam
esof
allimages
embedded
intextw
idget.
text ind
exindex
Returns
positionindex
inline.char
notation.
text insertindex
[string[tagL
iststring
tagList...]]
Insertstring
intotextatindex
applyingtags
fromtagL
ist.
text mark
gravity
markN
ame
[left|right
]R
eturns(or
sets)w
hichadjacent
charactera
mark
isattached
to.
text mark
nam
esR
eturnsa
listofthe
names
ofallm
arkscurrently
set.
text mark
next
|p
reviou
sindex
Return
name
ofnext/previous
mark
atorafter/before
index.
text mark
setm
arkNam
eindex
Setmark
markN
ame
toposition
justbeforecharacter
atindex.
text mark
un
setmarkN
ame
[markN
ame
...]R
emove
eachm
arkspecified
sothey
areno
longerusable
asindices.
text scanargs
SeeW
idgetScrollCom
mands
above.text search
[switches]
patternindex
[stopIndex]R
eturnsindex
offirstcharacter
matching
patternin
textrangeindex
tostopIndex.Sw
itches:-forwards,-backwards,
-exact,-regexp,-count
var,-nocase
textseeindex
Adjustthe
viewin
window
socharacter
atindexis
completely
visible.
text tagad
dtagN
ame
index1[index2]
Apply
tagtagN
ame
tocharacters
ingiven
range.
text tagb
ind
tagNam
e[sequence
[script]]A
rrangefor
scripttobe
runw
henevereventsequence
occursfor
acharacter
with
tagtagN
ame.
text tagcg
ettagNam
eoption
Return
currentvalueof
optionfor
tagtagN
ame.
text tagco
nfi
gu
retagN
ame
[option[value
[optionvalue
...]]]M
odifiestag-specific
optionsfor
thetag
tagNam
e.
text tagd
eletetagN
ame
[tagNam
e...]
Delete
alltaginform
ationfor
giventags.
text taglo
wer
tagNam
e[below
This]
Change
priorityof
tagtagN
ame
soitis
justbelowtag
belowT
his.
text tagn
ames
[index]R
eturnsa
listofthe
names
ofalltags
associatedw
ithcharacter
atindex.Ifindex
isnotgiven,returns
listofalltags
definedin
widget.
text tagn
extrang
etagN
ame
index1[index2]
Searchescharacter
rangeindex1
toindex2
(defaultend
)for
thefirstregion
taggedw
ithtagN
ame.R
eturnscharacter
rangeof
regionfound.
text tagp
revrang
etagN
ame
index1[index2]
Like
nextran
ge
butsearchesbackw
ardsfrom
index1to
index2(default
1.0).
text tagraise
tagNam
e[aboveT
his]C
hangepriority
oftag
tagNam
eso
itisjustabove
tagaboveT
his.
32
Tcl/T
kR
eference
Gu
ide
widgetxview
Return
atw
oelem
entlistspecifyingthe
fractionof
thehorizontalspan
ofthe
widgetatthe
leftandrightedges
ofthe
window
.
widgetxview
moveto
fractionA
djusttheview
inthe
window
sothatfraction
ofthe
totalwidth
ofthe
widgetis
off-screento
theleft.
widget xview
scrollnum
berunits|pages
Shifttheview
bynum
berone-tenths
(unit
)or
nine-tenths(pages
)the
window
’sw
idthin
thehorizontal
direction.
widget yview
Return
atw
oelem
entlistspecifyingthe
fractionof
theverticalspan
ofthe
widgetatthe
topand
bottomedges
ofthe
window
.
widget yview
moveto
fractionA
djusttheview
inthe
window
sothatfraction
ofthe
totalheightofthe
widgetis
off-screento
thetop.
widget yview
scrollnum
berunits|pages
Shifttheview
bynum
berone-tenths
(unit
)or
nine-tenths(pages
)the
window
’sheightin
theverticaldirection.
The
TextWidgetalso
supportsthe
following:
text yview[-pickplace
]index
Changes
viewof
widget’s
window
tom
akecharacter
atindexvisible.If
-pickplace
isspecified,index
willappear
atthetop
ofthe
window
.
The
Entry
(xviewonly)
andL
istboxW
idgetalsosupports
thefollow
ing:
listboxxview
indexA
djustsview
sothatcharacter
positionindex
isatleftedge.
listboxyview
indexA
djustsview
sothatelem
entatindexis
attopof
window
.
21.Th
eC
anvasW
idg
et
Canvas
Options
-background
-insertbackground
-selectborderwidth
-borderwidth
-insertborderwidth-selectforeground
-cursor
-insertofftime
-takefocus
-height
-insertontime
-width
-highlightbackground
-insertwidth
-xscrollcommand
-highlightcolor
-relief
-yscrollcommand
-highlightthickness
-selectbackground
-closeenough
floatH
owclose
them
ousecursor
mustbe
toan
itembefore
itisconsidered
tobe
“inside”the
item.
-confine
booleanW
hetheritis
allowable
tosetthe
canvas’sview
outsidethe
scrollregion.
-scrollregion
cornersL
istoffour
coordinatesdescribing
theleft,top,right,and
bottomof
arectangular
scrollingregion.
-xscrollincrement
distanceSpecifies
theincrem
entforhorizontal
scrollingin
screenunits.
21
Tcl/T
kR
eference
Gu
ide
-yscrollincrement
distanceSpecifies
theincrem
entforverticalscrolling
inscreen
units.
Coordinate
examples:5
(pixel),2.2i(inch),4.1c(cm
),3m(m
m),21p
(pts)
Larger
y-coordinatesrefer
topoints
lower
onthe
screen.
Larger
x-coordinatesrefer
topoints
fartherto
theright.
Character
positions:charIndex,
end
,insert
,sel.first
,sel.last
,@x,y
Canvas
Com
mands
canvasad
dtag
tagsearchSpec
[argarg
...]A
ddtag
tothe
listoftags
associatedw
itheach
itemthatsatisfy
searchSpec.See
Canvas
SearchSpecs
below.
canvasb
box
tagOrId
[tagOrId
...]R
eturnsa
listwith
fourelem
entsgiving
anapproxim
atebounding
boxfor
allthe
items
named
bythe
tagOrId
arguments.
canvasb
ind
tagOrId
[sequence[com
mand]]
Associates
comm
andto
beinvoked
onevents
specifiedw
ithsequence
with
theitem
sgiven
bytagO
rId.
canvascanvasx
screenx[gridspacing]
Returns
thecanvas
x-coordinatethatis
displayedatscreen
x-coordinatescreenx
possiblyrounding
tonearestm
ultipleof
gridspacingunits.
canvascanvasy
screeny[gridspacing]
Returns
thecanvas
x-coordinatethatis
displayedatscreen
y-coordinatescreeny
possiblyrounding
tonearestm
ultipleof
gridspacingunits.
canvasco
ord
stagO
rId[x0
y0...]
Query
orm
odifythe
coordinatesthatdefine
anitem
.
canvascreate
typex
y[x
y...]
[optionvalue
...]C
reatea
newitem
oftype
typeatspecified
coordinatesand
with
listoptions.
canvasd
chars
tagOrId
first[last]For
items
givenby
tagOrId,delete
thecharacters
inthe
rangegiven
byfirst
andlast(defaults
tofirst),inclusive.
canvasd
elete[tagO
rId...]
Delete
eachof
theitem
sgiven
byeach
tagOrId.
canvasd
tagtagO
rId[tagToD
elete]R
emove
tagtagToD
eletefrom
thetaglistof
items
givenby
tagOrId.
canvasfi
nd
searchSpec[arg
arg...]
Returns
alistof
theitem
sthatsatisfy
thespecification
searchSpec.SeeC
anvasSearch
Specsbelow
.
canvasfo
cus
tagOrId
Setthefocus
tothe
firsttextualitemgiven
bytagO
rId.
canvasg
ettags
tagOrId
Return
alistof
thetags
associatedw
iththe
firstitemgiven
bytagO
rId.
canvasicu
rsor
tagOrId
indexSetthe
insertioncursor
forthe
item(s)
givenby
tagOrId
tojustbefore
thecharacter
positionindex
.
canvasin
dex
tagOrId
indexR
eturnsa
decimalstring
givingthe
numericalindex
within
tagOrId
correspondingto
characterposition
index.
22
Tcl/T
kR
eference
Gu
ide
Text
Em
beddedW
indowO
ptions
-aligntop|center|bottom|baseline
How
window
isvertically
alignedw
ithits
line.
-create
scriptScriptto
createand
returnw
indowpathnam
eif
no-window
optionis
given.
-padx
width
Extra
spacein
screenunits
toleave
onthe
leftandrightside
ofw
indow.
-pady
heightE
xtraspace
inscreen
unitsto
leaveon
thetop
andbottom
ofw
indow.
-stretch
booleanW
hetherw
indowshould
bestretched
verticallyto
fillline.
-window
pathNam
eN
ame
ofw
indowto
display.
Text
Em
beddedIm
ageO
ptions
-aligntop|center|bottom|baseline
Where
image
isdisplayed
onthe
line.
-image
image
SpecifiesT
kim
ageto
usefor
embedded
image.
-name
imageN
ame
Specifiesnam
ew
hichm
aybe
usedto
referencethe
embedded
image.
-padx
width
Extra
spacein
screenunits
toleave
onthe
leftandrightside
ofim
age.
-pady
heightE
xtraspace
inscreen
unitsto
leaveon
thetop
andbottom
ofim
age.
Text
Widget
Com
mands
textbb
oxindex
Returns
alist
{x
yw
idthheight}
boundingcharacter
atindex.
textcom
pare
index1op
index2C
ompares
indicesindex1
andindex2
accordingto
relationaloperator
op.
text delete
index1[index2]
Delete
rangeof
giventextrange.
text dlin
einfo
indexR
eturnsa
list{
xy
width
heightbaseline}
describingthe
screenarea
takenby
displayline
atindex.
text du
mp
[switches]
index1[index2]
Returns
detailedinfo
ontextw
idgetcontentsin
giventextrange.Sw
itchesinclude
-all
,-mark
,-tag
,-text
,-window
forspecifying
typeof
inforeturned.T
hesw
itch-command
comm
andexists
toinvoke
aprocedure
oneach
elementtype
inthe
range.
text getindex1
[index2]R
eturnsstring
ofcharacters
ingiven
range.
text imag
ecg
etindexoption
Return
currentvalueof
optionfor
embedded
image
atindex.
textimag
eco
nfi
gu
reindex
[option[value
[optionvalue
...]]]M
odifiesem
beddedim
age-specificoptions
forthe
image
atindex.
31
Tcl/T
kR
eference
Gu
ide
-variable
variableN
ame
ofglobalvariable
tosetw
hencheckbutton
orradiobutton
isselected.
25.Th
eText
Wid
get
Text
Widget
Options
-background
-highlightthickness-selectbackground
-borderwidth
-insertbackground
-selectborderwidth
-cursor
-insertborderwidth
-selectforeground
-exportselection
-insertofftime
-setgrid
-font
-insertontime
-state
-foreground
-insertwidth
-takefocus
-height
-padx
-width
-highlightbackground-pady
-xscrollcommand
-highlightcolor
-relief
-yscrollcommand
-spacing1
sizeSpace
inscreen
unitsabove
paragraphs.
-spacing2
sizeSpace
inscreen
unitsbetw
eenparagraph
lines.
-spacing3
sizeSpace
inscreen
unitsbelow
paragraphs.
-tabs
tabList
Setoftab
stopsas
alistof
screendistances
givingtheir
positions.Each
stopm
aybe
followed
byone
ofleft
,right
,center
,ornumeric
.
-wrapnone|char|word
How
tow
raplines.
Text
Indices
Syntax:base
[modifier
...]
Base:
line.char, @x,y,e
nd
,mark,tag.f
irst
,tag.last
,pathNam
e(em
beddedw
indow),im
ageNam
e(em
beddedim
age)
Modifier:
�
countchars
,
�
countlines
,linestart
,lineend
,wordstart
,wordend
Ranges:
Ranges
includeallcharacters
fromthe
startindexup
tobutnot
includingthe
characteratthe
stopindex.
Text
Tag
Options
-background
-justify
-spacing2
-borderwidth
-relief
-spacing3
-font
-spacing1
-wrap
-foreground
-bgstipple
bitmap
Stipplepattern
forbackground.
-fgstipple
bitmap
Stipplepattern
forforeground.
-lmargin1
sizeL
eftmargin
offirstline
ofa
paragraph.
-lmargin2
sizeL
eftmargin
ofw
rappedlines
ofa
paragraph.
-offset
sizeO
ffsetofbaseline
fromnorm
albaseline.
-overstrike
booleanW
hetherto
overstriketext.
-rmargin
sizeR
ightmargin
ofalllines.
-tabs
tabList
Setoftab
stops(see
-tabs
above).
-underline
booleanW
hetherto
underlinetext.
30
Tcl/T
kR
eference
Gu
ide
canvasin
serttagO
rIdbeforeT
hisstring
Insertstring
justbeforecharacter
positionbeforeT
hisin
items
givenby
tagOrId
thatsupporttextualinsertion.
canvasitem
cgettagO
rIdoption
Returns
thevalue
optionfor
theitem
givenby
tagOrId.
canvasitem
con
fig
ure
tagOrId
[optionvalue
...]M
odifiesitem
-specificoptions
forthe
items
givenby
tagOrId.
canvaslo
wer
tagOrId
[belowT
his]M
ovethe
items
givenby
tagOrId
toa
newposition
inthe
displaylistjust
beforethe
firstitemgiven
bybelow
This.
canvasm
ovetagO
rIdxA
mountyA
mount
Move
theitem
sgiven
bytagO
rIdin
thecanvas
coordinatespace
byadding
xAm
ountandyA
mountto
eachitem
sx
andy
coordinates,respectively.
canvasp
ostscrip
t[optionvalue
...]G
eneratea
Encapsulated
Postscriptrepresentation
forpartor
allofthe
canvas.SeeC
anvasPostscript
Options
below.
canvasraise
tagOrId
[aboveThis]
Move
theitem
sgiven
bytagO
rIdto
anew
positionin
thedisplay
listjustafter
thefirstitem
givenby
aboveThis.
canvasscale
tagOrId
xOrigin
yOrigin
xScaleyScale
Rescale
items
givenby
tagOrId
incanvas
coordinatespace
tochange
thedistance
fromxO
rigin,yOrigin
bya
factorof
xScale,yScalerespectively.
canvasscan
argsSee
WidgetScrollC
omm
andsabove.
canvasselect
adju
sttagOrId
indexA
djustnearestendof
currentselectionin
tagOrId
tobe
atindexand
settheother
endto
bethe
newselection
anchor.
canvasselect
clearC
learthe
selectionif
itisin
thew
idget.
canvasselect
from
tagOrId
indexSetthe
selectionanchor
intagO
rIdto
justbeforethe
characteratindex.
canvasselect
itemR
eturnid
ofthe
selecteditem
.Returns
aem
ptystring
ifthere
isnone.
canvasselect
totagO
rIdindex
Settheselection
toextend
between
indexand
anchorpointin
tagOrId.
canvastyp
etagO
rIdR
eturnsthe
typeof
thefirstitem
givenby
tagOrId.
canvasxview
|yview
argsSee
WidgetScrollC
omm
andsabove.
Canvas
SearchSpecifications
above
tagOrId
Selectsthe
itemjustafter
theone
givenby
tagOrId
inthe
displaylist.
allSelects
alltheitem
sin
thecanvas.
belo
wtagO
rIdSelects
theitem
justbeforethe
onegiven
bytagO
rIdin
thedisplay
list.
closest
xy
[halo][start]
Selectthetopm
ost,closestitemto
@x,y
thatisbelow
startinthe
displaylist.
Any
itemcloser
thanhalo
tothe
pointisconsidered
tooverlap
it.
23
Tcl/T
kR
eference
Gu
ide
enclo
sedx1
y1x2
y2Selects
alltheitem
scom
pletelyenclosed
within
x1y1
x2y2.
overlapp
ing
x1y1
x2y2
Selectsallthe
items
thatoverlapor
areenclosed
within
x1y1
x2y2.
with
tagtagO
rIdSelects
alltheitem
sgiven
bytagO
rId.
Canvas
ItemT
ypes
canvascreate
arcx1
y1x2
y2[option
value...]
-fill
color-stipple
bitmap
-width
outlineWidth
-outline
color-tags
tagList
-extent
degreesSize
ofthe
angularrange
occupiedby
arc.
-outlinestipple
bitmap
Bitm
apstipple
touse
todraw
arc’soutline.
-start
degreesStarting
anglem
easuredfrom
3-o’clockposition.
-stylepieslice|chord|arc
How
to“com
plete”the
regionof
thearc.
canvascreate
bitm
apx
y[option
value...]
-anchor
anchorPos-bitmap
bitmap
-tags
tagslist-background
color-foreground
color
canvascreate
imag
ex
y[option
value...]
-anchor
anchorPos-image
image
-tags
tagslist
canvascreate
line
x1y1
...xNyN
[optionvalue
...]
-fill
color-stipple
bitmap
-width
outlineWidth
-smooth
boolean-tags
tagList
-arrownone|first|last|both
Specifyon
which
endsof
theline
todraw
arrows.
-arrowshape
shapeT
hreeelem
entlistwhich
describesshape
ofarrow
.
-capstylebutt|projecting|round
How
todraw
capsatendpoints
ofthe
line.Defaultis
butt
.
-joinstylebevel|miter|round
How
jointsare
tobe
drawn
atvertices.Defaultis
miter
.
-splinesteps
number
Degree
ofsm
oothnessdesired
forcurves.
canvascreate
ovalx1y1
x2y2
[optionvalue
...]
-fill
color-stipple
bitmap
-width
outlineWidth
-outline
color-tags
tagList
canvascreate
po
lygo
nx1
y1...xN
yN[option
value...]
-fill
color-smooth
boolean-tags
tagList
-outline
color-stipple
bitmap
-width
outlineWidth
24
Tcl/T
kR
eference
Gu
ide
menu
ind
exindex
Returns
thenum
ericalindex
correspondingto
index.
menu
insert
indextype
[optionvalue
...]Sam
eas
add
butinsertsnew
entryjustbefore
entryatindex.
menu
invoke
indexInvoke
theaction
ofthe
menu
entryatindex.
menu
po
stxy
Display
menu
onscreen
atroot-window
coordinatesgiven
byx
y.
menu
po
stcascade
indexPostsubm
enuassociated
with
cascadeentry
atindex.
menu
type
indexR
eturnstype
ofm
enuentry
atindex.
menu
un
po
stU
nmap
window
soitis
nolonger
displayed.
menu
ypo
sition
indexR
eturnsthe
y-coordinatew
ithinthe
menu
window
ofthe
topmostpixelin
theentry
specifiedby
index.
Menu
Entry
Options
The
following
optionsw
orkfor
allcascade,checkbutton,comm
and,andradiobutton
entriesunless
otherwise
specified.
-activebackground
-bitmap
-image
-activeforeground
-font
-state
-background
-foreground
-underline
-accelerator
stringSpecifies
stringto
displayatrightside
ofm
enuentry.
-command
tclCom
mand
TC
Lcom
mand
toevaluate
when
entryis
invoked.
-columnbreak
valueW
henvalue
is1,entry
appearsattop
ofa
newcolum
nin
menu.
-hidemargin
valueW
henvalue
is1,the
standardm
arginsare
notdrawn
aroundentry.
-indicatoron
booleanW
hetherindictor
forcheckbutton
orradiobutton
entryshould
bedisplayed.
-label
stringTextualstring
todisplay
onleftside
ofm
enuentry.
-menu
pathNam
ePathnam
eto
am
enuto
postwhen
cascadeentry
isactive.
-offvalue
valueV
alueto
storein
checkbuttonentry’s
associatedvariable
when
deselected.
-onvalue
valueV
alueto
storein
checkbuttonentry’s
associatedvariable
when
selected.
-selectcolor
colorC
olorfor
indicatorin
checkbuttonand
radiobuttonentries.
-selectimage
image
Image
todraw
inindicator
forcheckbutton
andradiobutton
entries.
-value
valueV
alueto
storein
radiobuttonentry’s
associatedvariable
when
selected.
29
Tcl/T
kR
eference
Gu
ide
listboxselectio
nset
first[last]A
ddallelem
entsbetw
eenfirstand
lastinclusiveto
selection.
listboxsee
indexA
djusttheview
inw
indowso
elementatindex
iscom
pletelyvisible.
listboxsize
Returns
number
ofelem
entsin
listbox.
listboxxview
|yview
argsSee
WidgetScrollC
omm
andsabove.
24.Th
eM
enu
Wid
get
Menu
Widget
Options
-activebackground
-borderwidth
-font
-activeborderwidth-cursor
-foreground
-activeforeground
-disabledforeground
-relief
-background
-postcommand
tclCom
mand
SpecifyT
clcomm
andto
invokeim
mediately
beforethe
menu
isposted.
-selectcolor
colorSpecifies
indicatorcolor
forcheckbutton
andradiobutton
entries.
-tearoff
booleanW
hetherto
includea
tear-offentry
attopof
menu.
-tearoffcommand
tclCm
dSpecifies
comm
andto
berun
when
menu
istorn
off.The
name
ofthe
menu
andthe
newtorn-off
window
willbe
appendedon
invocation.
-title
stringU
sesstring
fortitle
ofw
indowused
when
them
enuis
tornoff.
-type
typeU
sedatcreation
where
typeis
oneofmenubar
,tearoff
,ornormal
.
Entry
Types:cascade,checkbutton,command,radiobutton,
separator
Menu
Indices:num
ber,active,last,none,@
y-coord,matchPattern
Menu
Widget
Com
mands
menu
activateindex
Change
stateof
entryatindex
tobe
soleactive
entryin
menu.
menu
add
type[option
value...]
Add
newentry
oftype
typeto
bottomof
menu.See
belowfor
options.
menu
clon
enew
MenuN
ame
[cloneType]C
lonesm
enuas
anew
menu
newM
enuNam
eof
typecloneType
(see-type
).
menu
delete
index1[index2]
Delete
allentriesbetw
eenindex1
andindex2
inclusive.
menu
entrycg
etindexoption
Return
currentvalueof
optionfor
entryatindex.
menu
entryco
nfi
gu
reindex
[optionvalue
...]Setoption
valuesfor
entryatindex.
28
Tcl/T
kR
eference
Gu
ide
-splinesteps
number
Degree
ofsm
oothnessdesired
forcurved
perimeter.
canvascreate
rectang
lex1
y1x2
y2[option
value...]
-fill
color-stipple
bitmap
-width
outlineWidth
-outline
color-tags
tagList
canvascreate
textxy
[optionvalue
...]
-anchor
anchorPos-font
font-tags
tagList
-fill
color-stipple
bitmap
-text
string
-justifyleft|right|center
How
tojustify
textwithin
itsbounding
region.
-width
lineLength
Maxim
umline
lengthfor
thetext.If
zero,breakonly
on
nn.
canvascreate
win
do
wx
y[option
value...]
-anchor
anchorPos-tags
tagList
-height
heightH
eightinscreen
unitsto
assignitem
’sw
indow.
-width
width
Width
inscreen
unitsto
assignitem
’sw
indow.
-window
pathNam
eW
indowto
associatew
ithitem
.
Canvas
Postscript
Options
-colormap
varNam
eSpecifies
acolor
mapping
touse
where
varNam
eis
anarray
variablew
hoseelem
entsspecify
Postscriptcodeto
setaparticular
colorvalue.
-colormodecolor|grey|mono
Specifieshow
tooutputcolor
information.
-file
fileNam
eSpecifies
thenam
eof
thefile
inw
hichto
write
thePostscript.If
notspecified,the
Postscriptis
returnedas
theresultof
thecom
mand.
-fontmap
varNam
eSpecifies
afontm
appingto
usew
herevarN
ame
isan
arrayvariable
whose
elements
specifythe
Postscriptfontandsize
touse
asa
two
elementlist.
-height
sizeSpecifies
theheightof
thearea
ofthe
canvasto
print.Defaults
tothe
heightof
thecanvas
window
-pageanchor
anchorSpecifies
which
pointofthe
printedarea
shouldbe
appearover
thepositioning
pointonthe
page.Defaults
tocenter
.
-pageheight
sizeSpecifies
thatthePostscriptshould
bescaled
inboth
xand
yso
thattheprinted
areais
sizehigh
onthe
Postscriptpage.
-pagewidth
sizeSpecifies
thatthePostscriptshould
bescaled
inboth
xand
yso
thattheprinted
areais
sizew
ideon
thePostscriptpage.
-pagex
positionSetthe
x-coordinateof
thepositioning
pointonthe
pageto
position.
-pagey
positionSetthe
y-coordinateof
thepositioning
pointonthe
pageto
position.
25
Tcl/T
kR
eference
Gu
ide
-rotate
booleanW
hetherthe
printedarea
isto
berotated
90degrees.(“landscape”).
-width
sizeSpecifies
thew
idthof
thearea
ofthe
canvasto
print.Defaults
tothe
width
ofthe
canvasw
indow
-x
positionSetthe
x-coordinateof
theleftedge
ofcanvas
areato
print.
-y
positionSetthe
y-coordinateof
thetop
edgeof
canvasarea
toprint.
22.Th
eE
ntry
Wid
get
Entry
Widget
Options
-background
-highlightcolor
-relief
-borderwidth
-highlightthickness
-selectbackground
-cursor
-insertbackground
-selectborderwidth
-exportselection
-insertborderwidth
-selectforeground
-font
-insertofftime
-state
-foreground
-insertontime
-takefocus
-highlightbackground-insertwidth
-textvariable
-justify
-width
-show
charShow
charrather
thanactualcharacters
foreach
characterin
entry.
Entry
Indices:num
ber, anchor,end,insert,sel.first,
sel.last,
@x-coord
Entry
Widget
Com
mands
entryb
box
indexR
eturnsbounding
boxof
charactergiven
byindex.
entryd
eletefirst[last]
Delete
charactersfrom
firstthroughcharacter
justbeforelast.
entryg
etR
eturnsthe
entry’sstring.
entryicu
rsor
indexD
isplayinsertion
cursorjustbefore
characteratindex.
entryin
dex
indexR
eturnsthe
numerical
indexcorresponding
toindex.
entryin
sertindex
stringInsert
stringjustbefore
characteratindex.
entryscan
optionargs
SeeW
idgetScrollCom
mands
above.
entryselectio
nad
justindex
Adjustnearestend
ofcurrentselection
tobe
atindexand
settheother
endto
theanchor
point.
entryselectio
nclear
Clear
theselection
ifcurrently
inthe
widget.
entryselectio
nfro
mindex
Settheanchor
pointtobe
atindex.
26
Tcl/T
kR
eference
Gu
ide
entryselectio
np
resent
Returns
1is
anycharacters
areselected,0
otherwise.
entryselectio
nran
ge
startendSelectthe
charactersfrom
startthroughcharacter
justbeforeend.
entryselectio
nto
indexSetthe
selectionto
extendbetw
eenindex
andanchor
point.
23.Th
eL
istbox
Wid
get
Listbox
Widget
Options
-background
-height
-selectborderwidth
-borderwidth
-highlightbackground-selectforeground
-cursor
-highlightcolor
-setgrid
-exportselection
-highlightthickness-takefocus
-font
-relief
-width
-foreground
-selectbackground
-xscrollcommand
-yscrollcommand
-selectMode
single|browse|multiple|extended
Listbox
Indices:num
ber(starts
at0),active
,anchor
,end
,@x,y
Listbox
Widget
Com
mands
listboxactivate
indexSets
theactive
elementto
index.
listboxb
box
indexR
eturnsa
list{
xy
width
height}bounding
elementatindex.
listboxcu
rselection
Returns
listofindices
ofallelem
entscurrently
selected.
listboxd
eleteindex1
[index2]D
eleterange
ofelem
entsfrom
index1to
index2(defaults
toindex1).
listboxg
etindex1[index2]
Return
asa
listcontentsof
elements
fromindex1
toindex2.
listboxin
dex
indexR
eturnsposition
indexin
number
notation.
listboxin
sertindex[elem
ent...]Insertspecified
elements
justbeforeelem
entatindex.
listboxn
earesty
Return
indexof
elementnearest
toy-coordinate.
listboxscan
argsSee
WidgetScrollC
omm
andsabove.
listboxselectio
nan
cho
rindex
Settheselection
anchorto
elementatindex.
listboxselectio
nclear
first[last]D
eselectelements
between
firstandlastinclusive.
listboxselectio
nin
clud
esindex
Returns
1if
elementatindex
isselected,0
otherwise.
27