1canvas(n)                    Tk Built-In Commands                    canvas(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       canvas - Create and manipulate canvas widgets
9

SYNOPSIS

11       canvas pathName ?options?
12

STANDARD OPTIONS

14       -background           -insertborderwidth   -selectborderwidth
15       -borderwidth          -insertofftime       -selectforeground
16       -cursor               -insertontime        -takefocus
17       -highlightbackground  -insertwidth         -xscrollcommand
18       -highlightcolor       -relief              -yscrollcommand
19       -highlightthickness   -state
20       -insertbackground     -selectbackground
21
22       See the options manual entry for details on the standard options.
23

WIDGET-SPECIFIC OPTIONS

25       [-closeenough closeEnough]  Specifies a floating-point value indicating
26       how close the mouse cursor must be to an item before it  is  considered
27       to be ``inside'' the item.  Defaults to 1.0.  [-confine confine] Speci‐
28       fies a boolean value that indicates whether or not it should be  allow‐
29       able to set the canvas's view outside the region defined by the scroll‐
30       Region argument.  Defaults to true, which means that the view  will  be
31       constrained  within  the  scroll  region.  [-height height] Specifies a
32       desired window height that the canvas widget should  request  from  its
33       geometry  manager.   The  value  may  be  specified in any of the forms
34       described in the COORDINATES section  below.   [-scrollregion scrollRe‐
35       gion]  Specifies a list with four coordinates describing the left, top,
36       right, and bottom coordinates of a rectangular region.  This region  is
37       used for scrolling purposes and is considered to be the boundary of the
38       information in the canvas.  Each of the coordinates may be specified in
39       any   of   the   forms   given   in   the  COORDINATES  section  below.
40       [-state state] Modifies the default state of the canvas where state may
41       be  set  to  one  of:  normal,  disabled,  or hidden. Individual canvas
42       objects all have their own state option which may override the  default
43       state.   Many  options  can  take separate specifications such that the
44       appearance of the item can be different in  different  situations.  The
45       options  that  start  with active control the appearence when the mouse
46       pointer is over it, while the option starting  with  disabled  controls
47       the appearence when the state is disabled.  Canvas items which are dis‐
48       abled will not react to canvas bindings.   [-width width]  Specifies  a
49       desired  window  width  that  the canvas widget should request from its
50       geometry manager.  The value may be  specified  in  any  of  the  forms
51       described   in   the   COORDINATES   section   below.   [-xscrollincre‐
52       ment xScrollIncrement] Specifies an increment for horizontal scrolling,
53       in any of the usual forms permitted for screen distances.  If the value
54       of this option is greater than zero, the horizontal view in the  window
55       will be constrained so that the canvas x coordinate at the left edge of
56       the window is always an even multiple  of  xScrollIncrement;   further‐
57       more,  the  units for scrolling (e.g., the change in view when the left
58       and  right  arrows  of  a  scrollbar  are  selected)   will   also   be
59       xScrollIncrement.  If the value of this option is less than or equal to
60       zero, then  horizontal  scrolling  is  unconstrained.   [-yscrollincre‐
61       ment yScrollIncrement]  Specifies  an increment for vertical scrolling,
62       in any of the usual forms permitted for screen distances.  If the value
63       of  this  option  is greater than zero, the vertical view in the window
64       will be constrained so that the canvas y coordinate at the top edge  of
65       the  window  is  always an even multiple of yScrollIncrement;  further‐
66       more, the units for scrolling (e.g., the change in view  when  the  top
67       and   bottom   arrows  of  a  scrollbar  are  selected)  will  also  be
68       yScrollIncrement.  If the value of this option is less than or equal to
69       zero, then vertical scrolling is unconstrained.
70_________________________________________________________________
71
72

INTRODUCTION

74       The  canvas  command  creates a new window (given by the pathName argu‐
75       ment) and makes it into a canvas widget.  Additional options, described
76       above,  may  be specified on the command line or in the option database
77       to configure aspects of the canvas such as its colors and  3-D  relief.
78       The  canvas  command  returns  its pathName argument.  At the time this
79       command is invoked, there must not exist a window named  pathName,  but
80       pathName's parent must exist.
81
82       Canvas  widgets  implement  structured graphics.  A canvas displays any
83       number of items, which may be things like rectangles,  circles,  lines,
84       and text.  Items may be manipulated (e.g. moved or re-colored) and com‐
85       mands may be associated with items in much the same way that  the  bind
86       command allows commands to be bound to widgets.  For example, a partic‐
87       ular command may be associated with the <Button-1> event  so  that  the
88       command  is  invoked whenever button 1 is pressed with the mouse cursor
89       over an item.  This means that items in a  canvas  can  have  behaviors
90       defined by the Tcl scripts bound to them.
91

DISPLAY LIST

93       The  items  in  a  canvas are ordered for purposes of display, with the
94       first item in the display list being displayed first, followed  by  the
95       next  item  in  the  list,  and so on.  Items later in the display list
96       obscure those that are earlier in the display list  and  are  sometimes
97       referred  to  as being ``on top'' of earlier items.  When a new item is
98       created it is placed at the end of the display list, on top  of  every‐
99       thing else.  Widget commands may be used to re-arrange the order of the
100       display list.
101
102       Window items are an exception to the above rules.  The underlying  win‐
103       dow  systems require them always to be drawn on top of other items.  In
104       addition, the stacking order of window items is not affected by any  of
105       the  canvas  widget  commands; you must use the raise and lower Tk com‐
106       mands instead.
107

ITEM IDS AND TAGS

109       Items in a canvas widget may be named in either of two ways: by  id  or
110       by  tag.   Each item has a unique identifying number, which is assigned
111       to that item when it is created.  The id of an item never  changes  and
112       id numbers are never re-used within the lifetime of a canvas widget.
113
114       Each  item  may also have any number of tags associated with it.  A tag
115       is just a string of characters, and it may take any form except that of
116       an  integer.   For example, ``x123'' is OK but ``123'' isn't.  The same
117       tag may be associated with many different items.  This is commonly done
118       to  group items in various interesting ways;  for example, all selected
119       items might be given the tag ``selected''.
120
121       The tag all is implicitly associated with every item in the canvas;  it
122       may be used to invoke operations on all the items in the canvas.
123
124       The  tag current is managed automatically by Tk; it applies to the cur‐
125       rent item, which is the topmost item whose drawn area covers the  posi‐
126       tion  of the mouse cursor.  If the mouse is not in the canvas widget or
127       is not over an item, then no item has the current tag.
128
129       When specifying items in canvas widget commands, if the specifier is an
130       integer  then  it  is assumed to refer to the single item with that id.
131       If the specifier is not an integer, then it is assumed to refer to  all
132       of the items in the canvas that have a tag matching the specifier.  The
133       symbol tagOrId is used below to indicate  that  an  argument  specifies
134       either  an  id that selects a single item or a tag that selects zero or
135       more items.
136
137       tagOrId may contain a logical expressions of tags by  using  operators:
138       '&&', '||', '^' '!', and parenthesized subexpressions.  For example:
139                    .c find withtag {(a&&!b)||(!a&&b)}
140       or equivalently:
141                    .c find withtag {a^b}
142       will find only those items with either "a" or "b" tags, but not both.
143
144       Some  widget  commands  only  operate  on  a single item at a time;  if
145       tagOrId is specified in a way that names multiple items, then the  nor‐
146       mal  behavior  is  for  the  command to use the first (lowest) of these
147       items in the display list that is suitable for the command.  Exceptions
148       are noted in the widget command descriptions below.
149

COORDINATES

151       All  coordinates  related to canvases are stored as floating-point num‐
152       bers.  Coordinates and distances are specified in screen  units,  which
153       are  floating-point  numbers optionally followed by one of several let‐
154       ters.  If no letter is supplied then the distance is in pixels.  If the
155       letter  is  m then the distance is in millimeters on the screen;  if it
156       is c then the distance is in centimeters; i means inches, and  p  means
157       printers  points  (1/72  inch).   Larger  y-coordinates refer to points
158       lower on the screen;  larger x-coordinates refer to points  farther  to
159       the  right.   Coordinates  can be specified either as an even number of │
160       parameters, or as a single list parameter containing an even number  of │
161       x and y coordinate values.
162

TRANSFORMATIONS

164       Normally  the  origin  of the canvas coordinate system is at the upper-
165       left corner of the window containing the canvas.   It  is  possible  to
166       adjust  the origin of the canvas coordinate system relative to the ori‐
167       gin of the window using the xview and yview widget commands;   this  is
168       typically used for scrolling.  Canvases do not support scaling or rota‐
169       tion of the canvas coordinate system relative to the window  coordinate
170       system.
171
172       Individual items may be moved or scaled using widget commands described
173       below, but they may not be rotated.
174
175       Note that the default origin of the canvas's visible area is coincident
176       with  the  origin for the whole window as that makes bindings using the
177       mouse position easier to work with; you only need to  use  the  canvasx
178       and  canvasy  widget  commands  if you adjust the origin of the visible
179       area.  However, this also means that any focus ring (as  controlled  by
180       the -highlightthickness option) and window border (as controlled by the
181       -borderwidth option) must be taken into account before you get  to  the
182       visible area of the canvas.
183

INDICES

185       Text  items  support  the notion of an index for identifying particular
186       positions within the item.  In a  similar  fashion,  line  and  polygon
187       items  support index for identifying, inserting and deleting subsets of
188       their coordinates.  Indices are used for commands such as inserting  or
189       deleting  a  range of characters or coordinates, and setting the inser‐
190       tion cursor position. An index may be specified in any of a  number  of
191       ways,  and  different  types  of  items may support different forms for
192       specifying indices.  Text items support  the  following  forms  for  an
193       index;   if you define new types of text-like items, it would be advis‐
194       able to support as many of these forms as practical.  Note that  it  is
195       possible  to refer to the character just after the last one in the text
196       item;  this is necessary for such tasks as inserting new  text  at  the
197       end of the item.  Lines and Polygons don't support the insertion cursor
198       and the selection. Their  indices  are  supposed  to  be  even  always,
199       because coordinates always appear in pairs.
200
201       number    A decimal number giving the position of the desired character
202                 within the text item.  0 refers to the first character, 1  to
203                 the  next  character, and so on. If indexes are odd for lines
204                 and polygons, they will be automatically decremented by  one.
205                 A  number  less  than  0 is treated as if it were zero, and a
206                 number greater than the length of the text item is treated as
207                 if  it  were  equal to the length of the text item. For poly‐
208                 gons, numbers less than 0 or greater then the length  of  the
209                 coordinate list will be adjusted by adding or subtracting the
210                 length until the result  is  between  zero  and  the  length,
211                 inclusive.
212
213       end       Refers to the character or coordinate just after the last one
214                 in the item (same as the number of characters or  coordinates
215                 in the item).
216
217       insert    Refers  to the character just before which the insertion cur‐
218                 sor is drawn in this item. Not valid for lines and polygons.
219
220       sel.first Refers to the first selected character in the item.   If  the
221                 selection isn't in this item then this form is illegal.
222
223       sel.last  Refers  to  the  last selected character in the item.  If the
224                 selection isn't in this item then this form is illegal.
225
226       @x,y      Refers to the character or coordinate at the point given by x
227                 and  y,  where x and y are specified in the coordinate system
228                 of the canvas.  If x and y lie outside the  coordinates  cov‐
229                 ered  by  the text item, then they refer to the first or last
230                 character in the line that is closest to the given point.
231

DASH PATTERNS

233       Many items support the notion of a dash pattern for outlines.
234
235       The first possible syntax is a list of integers.  Each  element  repre‐
236       sents the number of pixels of a line segment. Only the odd segments are
237       drawn using the "outline" color. The other segments are drawn transpar‐
238       ent.
239
240       The second possible syntax is a character list containing only 5 possi‐
241       ble characters [.,-_ ]. The space can be  used  to  enlarge  the  space
242       between other line elements, and can not occur as the first position in
243       the string. Some examples:
244           -dash .= -dash {2 4}
245           -dash -     = -dash {6 4}
246           -dash -.    = -dash {6 4 2 4}
247           -dash -..   = -dash {6 4 2 4 2 4}
248           -dash {. }  = -dash {2 8}
249           -dash ,= -dash {4 4}
250
251       The main difference of this syntax with the  previous  is  that  it  is
252       shape-conserving.  This  means that all values in the dash list will be
253       multiplied by the line width before display. This assures that "." will
254       always be displayed as a dot and "-" always as a dash regardless of the
255       line width.
256
257       On systems which support only a limited set of dash patterns, the  dash
258       pattern  will  be  displayed as the closest dash pattern that is avail‐
259       able.  For example, on Windows only the first 4 of the  above  examples
260       are  available.   The  last 2 examples will be displayed identically to
261       the first one.
262

WIDGET COMMAND

264       The canvas command creates a new Tcl command whose  name  is  pathName.
265       This  command  may  be used to invoke various operations on the widget.
266       It has the following general form:
267              pathName option ?arg arg ...?
268       Option and the args determine the exact behavior of the  command.   The
269       following widget commands are possible for canvas widgets:
270
271       pathName addtag tag searchSpec ?arg arg ...?
272              For each item that meets the constraints specified by searchSpec
273              and the args, add tag to the list of tags  associated  with  the
274              item  if  it isn't already present on that list.  It is possible
275              that no items will satisfy the constraints given  by  searchSpec
276              and args, in which case the command has no effect.  This command
277              returns an empty string as result.   SearchSpec  and  arg's  may
278              take any of the following forms:
279
280              above tagOrId
281                     Selects  the  item  just  after  (above) the one given by
282                     tagOrId in the display list.   If  tagOrId  denotes  more
283                     than  one item, then the last (topmost) of these items in
284                     the display list is used.
285
286              all    Selects all the items in the canvas.
287
288              below tagOrId
289                     Selects the item just before (below)  the  one  given  by
290                     tagOrId  in  the  display  list.  If tagOrId denotes more
291                     than one item, then the first (lowest) of these items  in
292                     the display list is used.
293
294              closest x y ?halo? ?start?
295                     Selects  the  item closest to the point given by x and y.
296                     If more than one item is at  the  same  closest  distance
297                     (e.g.  two items overlap the point), then the top-most of
298                     these items (the last one in the display list)  is  used.
299                     If  halo  is  specified,  then  it must be a non-negative
300                     value.  Any item closer than halo to the point is consid‐
301                     ered  to  overlap  it.  The start argument may be used to
302                     step circularly through all the closest items.  If  start
303                     is  specified,  it names an item using a tag or id (if by
304                     tag, it selects the first item in the display  list  with
305                     the given tag).  Instead of selecting the topmost closest
306                     item, this form will select the topmost closest item that
307                     is  below  start  in  the  display list;  if no such item
308                     exists, then the selection behaves as if the start  argu‐
309                     ment had not been specified.
310
311              enclosed x1 y1 x2 y2
312                     Selects all the items completely enclosed within the rec‐
313                     tangular region given by x1, y1, x2, and y2.  X1 must  be
314                     no greater then x2 and y1 must be no greater than y2.
315
316              overlapping x1 y1 x2 y2
317                     Selects all the items that overlap or are enclosed within
318                     the rectangular region given by x1, y1, x2, and  y2.   X1
319                     must be no greater then x2 and y1 must be no greater than
320                     y2.
321
322              withtag tagOrId
323                     Selects all the items given by tagOrId.
324
325       pathName bbox tagOrId ?tagOrId tagOrId ...?
326              Returns a list with four elements giving an approximate bounding
327              box  for all the items named by the tagOrId arguments.  The list
328              has the form ``x1 y1 x2 y2'' such that the drawn  areas  of  all
329              the  named  elements  are within the region bounded by x1 on the
330              left, x2 on the right, y1 on the top, and y2 on the bottom.  The
331              return  value  may overestimate the actual bounding box by a few
332              pixels.  If no items match any of the tagOrId  arguments  or  if
333              the  matching  items  have  empty bounding boxes (i.e. they have
334              nothing to display) then an empty string is returned.
335
336       pathName bind tagOrId ?sequence? ?command?
337              This command associates command with  all  the  items  given  by
338              tagOrId  such that whenever the event sequence given by sequence
339              occurs for one of the items the command will be  invoked.   This
340              widget  command  is  similar  to the bind command except that it
341              operates on items in a canvas rather than entire  widgets.   See
342              the  bind  manual  entry  for  complete details on the syntax of
343              sequence and  the  substitutions  performed  on  command  before
344              invoking  it.  If all arguments are specified then a new binding
345              is created, replacing any existing binding for the same sequence
346              and  tagOrId  (if  the  first character of command is ``+'' then
347              command augments an existing binding rather than replacing  it).
348              In this case the return value is an empty string.  If command is
349              omitted then the command returns  the  command  associated  with
350              tagOrId  and sequence (an error occurs if there is no such bind‐
351              ing).  If both command and sequence are omitted then the command
352              returns a list of all the sequences for which bindings have been
353              defined for tagOrId.
354
355              The only events for which bindings may be  specified  are  those
356              related to the mouse and keyboard (such as Enter, Leave, Button‐
357              Press, Motion, and KeyPress) or virtual events.  The handling of
358              events in canvases uses the current item defined in ITEM IDS AND
359              TAGS above.  Enter and Leave events trigger for an item when  it
360              becomes  the current item or ceases to be the current item; note
361              that these events are different than Enter and Leave events  for
362              windows.  Mouse-related events are directed to the current item,
363              if any.  Keyboard-related events are directed to the focus item,
364              if  any  (see  the focus widget command below for more on this).
365              If a virtual event is used in a binding, that binding can  trig‐
366              ger only if the virtual event is defined by an underlying mouse-
367              related or keyboard-related event.
368
369              It is possible for  multiple  bindings  to  match  a  particular
370              event.  This could occur, for example, if one binding is associ‐
371              ated with the item's id and another is associated  with  one  of
372              the item's tags.  When this occurs, all of the matching bindings
373              are invoked.  A binding associated with the all tag  is  invoked
374              first,  followed  by one binding for each of the item's tags (in
375              order), followed by a binding associated with the item's id.  If
376              there are multiple matching bindings for a single tag, then only
377              the most specific binding is invoked.  A continue command  in  a
378              binding  script terminates that script, and a break command ter‐
379              minates that script and skips  any  remaining  scripts  for  the
380              event, just as for the bind command.
381
382              If bindings have been created for a canvas window using the bind
383              command, then they are invoked in addition to  bindings  created
384              for the canvas's items using the bind widget command.  The bind‐
385              ings for items will be invoked before any of  the  bindings  for
386              the window as a whole.
387
388       pathName canvasx screenx ?gridspacing?
389              Given  a window x-coordinate in the canvas screenx, this command
390              returns the canvas x-coordinate that is displayed at that  loca‐
391              tion.   If  gridspacing is specified, then the canvas coordinate
392              is rounded to the nearest multiple of gridspacing units.
393
394       pathName canvasy screeny ?gridspacing?
395              Given a window y-coordinate in the canvas screeny  this  command
396              returns  the canvas y-coordinate that is displayed at that loca‐
397              tion.  If gridspacing is specified, then the  canvas  coordinate
398              is rounded to the nearest multiple of gridspacing units.
399
400       pathName cget option
401              Returns  the  current value of the configuration option given by
402              option.  Option may have any of the values accepted by the  can‐
403              vas command.
404
405       pathName configure ?option? ?value? ?option value ...?
406              Query  or modify the configuration options of the widget.  If no
407              option is specified, returns a list describing all of the avail‐
408              able  options for pathName (see Tk_ConfigureInfo for information
409              on the format of this list).  If option  is  specified  with  no
410              value,  then the command returns a list describing the one named
411              option (this list will be identical to the corresponding sublist
412              of  the  value  returned  if no option is specified).  If one or
413              more option-value pairs are specified, then the command modifies
414              the  given widget option(s) to have the given value(s);  in this
415              case the command returns an empty string.  Option may  have  any
416              of the values accepted by the canvas command.
417
418       pathName coords tagOrId ?x0 y0 ...?
419
420       pathName coords tagOrId ?coordList?
421              Query  or  modify  the  coordinates  that define an item.  If no
422              coordinates are specified, this command  returns  a  list  whose
423              elements  are  the coordinates of the item named by tagOrId.  If
424              coordinates are specified, then they replace the current coordi‐
425              nates  for the named item.  If tagOrId refers to multiple items,
426              then the first one in the display list is used.
427
428       pathName create type x y ?x y ...? ?option value ...?
429
430       pathName create type coordList ?option value ...?
431              Create a new item in pathName of type type.  The exact format of
432              the  arguments after type depends on type, but usually they con‐
433              sist of the coordinates for one  or  more  points,  followed  by
434              specifications  for  zero or more item options.  See the subsec‐
435              tions on individual item types below for more on the  syntax  of
436              this command.  This command returns the id for the new item.
437
438       pathName dchars tagOrId first ?last?
439              For  each item given by tagOrId, delete the characters, or coor‐
440              dinates, in the range given by first and  last,  inclusive.   If
441              some of the items given by tagOrId don't support indexing opera‐
442              tions then they ignore dchars.  Text items interpret  first  and
443              last as indices to a character, line and polygon items interpret
444              them indices  to  a  coordinate  (an  x,y  pair).   Indices  are
445              described  in INDICES above.  If last is omitted, it defaults to
446              first.  This command returns an empty string.
447
448       pathName delete ?tagOrId tagOrId ...?
449              Delete each of the items given by each tagOrId,  and  return  an
450              empty string.
451
452       pathName dtag tagOrId ?tagToDelete?
453              For  each of the items given by tagOrId, delete the tag given by
454              tagToDelete from the list of those associated with the item.  If
455              an  item doesn't have the tag tagToDelete then the item is unaf‐
456              fected by the  command.   If  tagToDelete  is  omitted  then  it
457              defaults to tagOrId.  This command returns an empty string.
458
459       pathName find searchCommand ?arg arg ...?
460              This  command  returns  a  list consisting of all the items that
461              meet the  constraints  specified  by  searchCommand  and  arg's.
462              SearchCommand  and  args  have  any of the forms accepted by the
463              addtag command.  The items are returned in stacking order,  with
464              the lowest item first.
465
466       pathName focus ?tagOrId?
467              Set  the  keyboard focus for the canvas widget to the item given
468              by tagOrId.  If tagOrId refers to several items, then the  focus
469              is  set to the first such item in the display list that supports
470              the insertion cursor.  If tagOrId doesn't refer to any items, or
471              if  none  of  them  support the insertion cursor, then the focus
472              isn't changed.  If tagOrId is an empty string,  then  the  focus
473              item  is reset so that no item has the focus.  If tagOrId is not
474              specified then the command returns the id for the item that cur‐
475              rently  has  the  focus,  or  an empty string if no item has the
476              focus.
477
478              Once the focus has been set to an item, the  item  will  display
479              the insertion cursor and all keyboard events will be directed to
480              that item.  The focus item within a canvas and the focus  window
481              on  the screen (set with the focus command) are totally indepen‐
482              dent: a given item doesn't actually have the input focus  unless
483              (a) its canvas is the focus window and (b) the item is the focus
484              item within the canvas.  In most cases it is advisable to follow
485              the focus widget command with the focus command to set the focus
486              window to the canvas (if it wasn't there already).
487
488       pathName gettags tagOrId
489              Return a list whose elements are the tags  associated  with  the
490              item given by tagOrId.  If tagOrId refers to more than one item,
491              then the tags are returned from the first such item in the  dis‐
492              play  list.   If  tagOrId  doesn't refer to any items, or if the
493              item contains no tags, then an empty string is returned.
494
495       pathName icursor tagOrId index
496              Set the position of the insertion cursor for the  item(s)  given
497              by  tagOrId to just before the character whose position is given
498              by index.  If some or all of the items given  by  tagOrId  don't
499              support  an  insertion cursor then this command has no effect on
500              them.  See INDICES above for a description of  the  legal  forms
501              for  index.  Note:  the insertion cursor is only displayed in an
502              item if that item currently has the keyboard focus (see the wid‐
503              get  command  focus,  below), but the cursor position may be set
504              even when the item doesn't have the focus.  This command returns
505              an empty string.
506
507       pathName index tagOrId index
508              This command returns a decimal string giving the numerical index
509              within tagOrId corresponding to index.  Index  gives  a  textual
510              description  of  the  desired  position  as described in INDICES
511              above.  Text items interpret index as an index to a   character,
512              line  and polygon items interpret it as an index to a coordinate
513              (an x,y pair).  The return value is guaranteed to lie between  0
514              and  the  number of characters, or coordinates, within the item,
515              inclusive.  If tagOrId refers to multiple items, then the  index
516              is  processed in the first of these items that supports indexing
517              operations (in display list order).
518
519       pathName insert tagOrId beforeThis string
520              For each of the items given by tagOrId,  if  the  item  supports
521              text  or  coordinate, insertion then string is inserted into the
522              item's text just before  the  character,  or  coordinate,  whose
523              index  is  beforeThis.   Text  items  interpret beforeThis as an
524              index to a  character, line and polygon items interpret it as an
525              index to a coordinate (an x,y pair).  For lines and polygons the
526              string must be a valid coordinate sequence.  See  INDICES  above
527              for  information  about  the forms allowed for beforeThis.  This
528              command returns an empty string.
529
530       pathName itemcget tagOrId option
531              Returns the current value of the configuration  option  for  the
532              item  given  by  tagOrId  whose name is option.  This command is
533              similar to the cget widget command except that it applies  to  a
534              particular  item  rather than the widget as a whole.  Option may
535              have any of the values accepted by  the  create  widget  command
536              when  the  item was created.  If tagOrId is a tag that refers to
537              more than one item, the first (lowest) such item is used.
538
539       pathName itemconfigure tagOrId ?option? ?value? ?option value ...?
540              This command is similar to the configure widget  command  except
541              that  it  modifies  item-specific options for the items given by
542              tagOrId instead of modifying options for the overall canvas wid‐
543              get.   If  no option is specified, returns a list describing all
544              of the available options for the first  item  given  by  tagOrId
545              (see  Tk_ConfigureInfo  for  information  on  the format of this
546              list).  If option is specified with no value, then  the  command
547              returns  a  list describing the one named option (this list will
548              be identical to the corresponding sublist of the value  returned
549              if  no  option is specified).  If one or more option-value pairs
550              are specified,  then  the  command  modifies  the  given  widget
551              option(s)  to have the given value(s) in each of the items given
552              by tagOrId;  in this case the command returns an  empty  string.
553              The  options and values are the same as those permissible in the
554              create widget command when the item(s)  were  created;  see  the
555              sections  describing  individual item types below for details on
556              the legal options.
557
558       pathName lower tagOrId ?belowThis?
559              Move all of the items given by tagOrId to a new position in  the
560              display  list  just  before  the  item  given  by belowThis.  If
561              tagOrId refers to more than one item then all are moved but  the
562              relative   order  of  the  moved  items  will  not  be  changed.
563              BelowThis is a tag or id;  if it refers to more  than  one  item
564              then  the  first  (lowest) of these items in the display list is
565              used as the destination location for  the  moved  items.   Note:
566              this command has no effect on window items.  Window items always
567              obscure other item types, and the stacking order of window items
568              is determined by the raise and lower commands, not the raise and
569              lower widget commands for canvases.   This  command  returns  an
570              empty string.
571
572       pathName move tagOrId xAmount yAmount
573              Move each of the items given by tagOrId in the canvas coordinate
574              space by adding xAmount to the x-coordinate of each point  asso‐
575              ciated  with  the  item  and yAmount to the y-coordinate of each
576              point associated with the item.  This command returns  an  empty
577              string.
578
579       pathName postscript ?option value option value ...?
580              Generate a Postscript representation for part or all of the can‐
581              vas.  If the -file option is specified then  the  Postscript  is
582              written  to  a  file and an empty string is returned;  otherwise
583              the Postscript is returned as the result of the command.  If the
584              interpreter  that  owns the canvas is marked as safe, the opera‐
585              tion will fail because safe  interpreters  are  not  allowed  to
586              write  files.  If the -channel option is specified, the argument
587              denotes the name of a channel already opened  for  writing.  The
588              Postscript  is  written to that channel, and the channel is left
589              open for further writing at the end of the operation.  The Post‐
590              script  is created in Encapsulated Postscript form using version
591              3.0 of the Document Structuring Conventions.  Note:  by  default
592              Postscript is only generated for information that appears in the
593              canvas's window on the screen.  If the canvas is freshly created
594              it  may still have its initial size of 1x1 pixel so nothing will
595              appear in the Postscript.  To get  around  this  problem  either
596              invoke  the  "update"  command  to wait for the canvas window to
597              reach its final size, or else use the -width and -height options
598              to  specify  the  area of the canvas to print.  The option-value
599              argument pairs provide additional  information  to  control  the
600              generation of Postscript.  The following options are supported:
601
602              -colormap varName
603                     VarName must be the name of an array variable that speci‐
604                     fies a color mapping to use in the Postscript.  Each ele‐
605                     ment  of varName must consist of Postscript code to set a
606                     particular  color  value  (e.g.  ``1.0  1.0  0.0  setrgb‐
607                     color'').  When outputting color information in the Post‐
608                     script, Tk checks to see if there is an element  of  var‐
609                     Name with the same name as the color.  If so, Tk uses the
610                     value of the element as the Postscript command to set the
611                     color.  If this option hasn't been specified, or if there
612                     isn't an entry in varName for a given color, then Tk uses
613                     the red, green, and blue intensities from the X color.
614
615              -colormode mode
616                     Specifies  how to output color information.  Mode must be
617                     either color (for full color output), gray  (convert  all
618                     colors  to their gray-scale equivalents) or mono (convert
619                     all colors to black or white).
620
621              -file fileName
622                     Specifies the name of the file  in  which  to  write  the
623                     Postscript.   If  this  option  isn't  specified then the
624                     Postscript is returned  as  the  result  of  the  command
625                     instead of being written to a file.
626
627              -fontmap varName
628                     VarName must be the name of an array variable that speci‐
629                     fies a font mapping to use in the Postscript.  Each  ele‐
630                     ment  of varName must consist of a Tcl list with two ele‐
631                     ments, which are the name and point size of a  Postscript
632                     font.  When outputting Postscript commands for a particu‐
633                     lar font, Tk checks to see if varName contains an element
634                     with the same name as the font.  If there is such an ele‐
635                     ment, then the font information contained in that element
636                     is  used  in  the  Postscript.   Otherwise Tk attempts to
637                     guess what Postscript font to use.  Tk's  guesses  gener‐
638                     ally  only  work  for  well-known fonts such as Times and
639                     Helvetica and Courier, and only if the X font  name  does
640                     not omit any dashes up through the point size.  For exam‐
641                     ple,  -*-Courier-Bold-R-Normal--*-120-*  will  work   but
642                     *Courier-Bold-R-Normal*120*   will  not;   Tk  needs  the
643                     dashes to parse the font name).
644
645              -height size
646                     Specifies the height of the area of the canvas to  print.
647                     Defaults to the height of the canvas window.
648
649              -pageanchor anchor
650                     Specifies  which  point of the printed area of the canvas
651                     should appear over the  positioning  point  on  the  page
652                     (which  is  given by the -pagex and -pagey options).  For
653                     example, -pageanchor n means that the top center  of  the
654                     area  of  the  canvas being printed (as it appears in the
655                     canvas window) should  be  over  the  positioning  point.
656                     Defaults to center.
657
658              -pageheight size
659                     Specifies  that the Postscript should be scaled in both x
660                     and y so that the printed area is size high on the  Post‐
661                     script  page.   Size  consists of a floating-point number
662                     followed by c for centimeters, i for inches, m  for  mil‐
663                     limeters,  or  p  or  nothing  for printer's points (1/72
664                     inch).  Defaults to the height of the printed area on the
665                     screen.  If both -pageheight and -pagewidth are specified
666                     then the scale factor from -pagewidth is  used  (non-uni‐
667                     form scaling is not implemented).
668
669              -pagewidth size
670                     Specifies  that the Postscript should be scaled in both x
671                     and y so that the printed area is size wide on the  Post‐
672                     script  page.  Size has the same form as for -pageheight.
673                     Defaults to the width of the printed area on the  screen.
674                     If both -pageheight and -pagewidth are specified then the
675                     scale factor from -pagewidth  is used (non-uniform  scal‐
676                     ing is not implemented).
677
678              -pagex position
679                     Position  gives the x-coordinate of the positioning point
680                     on the Postscript page, using any of  the  forms  allowed
681                     for -pageheight.  Used in conjunction with the -pagey and
682                     -pageanchor options to determine where the  printed  area
683                     appears  on  the Postscript page.  Defaults to the center
684                     of the page.
685
686              -pagey position
687                     Position gives the y-coordinate of the positioning  point
688                     on  the  Postscript  page, using any of the forms allowed
689                     for -pageheight.  Used in conjunction with the -pagex and
690                     -pageanchor  options  to determine where the printed area
691                     appears on the Postscript page.  Defaults to  the  center
692                     of the page.
693
694              -rotate boolean
695                     Boolean  specifies  whether  the  printed  area  is to be
696                     rotated 90 degrees.  In non-rotated output the x-axis  of
697                     the  printed  area  runs along the short dimension of the
698                     page (``portrait'' orientation); in rotated output the x-
699                     axis  runs  along the long dimension of the page (``land‐
700                     scape'' orientation).  Defaults to non-rotated.
701
702              -width size
703                     Specifies the width of the area of the canvas  to  print.
704                     Defaults to the width of the canvas window.
705
706              -x position
707                     Specifies  the  x-coordinate of the left edge of the area
708                     of the canvas that is to be printed,  in  canvas  coordi‐
709                     nates,  not  window coordinates.  Defaults to the coordi‐
710                     nate of the left edge of the window.
711
712              -y position
713                     Specifies the y-coordinate of the top edge of the area of
714                     the  canvas that is to be printed, in canvas coordinates,
715                     not window coordinates.  Defaults to  the  coordinate  of
716                     the top edge of the window.
717
718       pathName raise tagOrId ?aboveThis?
719              Move  all of the items given by tagOrId to a new position in the
720              display list just after the item given by aboveThis.  If tagOrId
721              refers to more than one item then all are moved but the relative
722              order of the moved items will not be changed.   AboveThis  is  a
723              tag  or  id;   if  it refers to more than one item then the last
724              (topmost) of these items in the display list is used as the des‐
725              tination  location  for the moved items.  Note: this command has
726              no effect on window items.  Window items  always  obscure  other
727              item types, and the stacking order of window items is determined
728              by the raise and lower commands, not the raise and lower  widget
729              commands for canvases.  This command returns an empty string.
730
731       pathName scale tagOrId xOrigin yOrigin xScale yScale
732              Rescale  all  of the items given by tagOrId in canvas coordinate
733              space.  XOrigin and yOrigin identify the origin for the  scaling
734              operation  and  xScale and yScale identify the scale factors for
735              x- and  y-coordinates,  respectively  (a  scale  factor  of  1.0
736              implies  no  change to that coordinate).  For each of the points
737              defining each item, the x-coordinate is adjusted to  change  the
738              distance from xOrigin by a factor of xScale.  Similarly, each y-
739              coordinate is adjusted to change the distance from yOrigin by  a
740              factor of yScale.  This command returns an empty string.
741
742       pathName scan option args
743              This  command is used to implement scanning on canvases.  It has
744              two forms, depending on option:
745
746              pathName scan mark x y
747                     Records x and y and the canvas's current view;   used  in
748                     conjunction  with  later scan dragto commands.  Typically
749                     this command is associated with a mouse button  press  in
750                     the  widget and x and y are the coordinates of the mouse.
751                     It returns an empty string.
752
753              pathName scan dragto x y ?gain?.
754                     This command computes the difference between its x and  y
755                     arguments (which are typically mouse coordinates) and the
756                     x and y arguments to the last scan mark command  for  the
757                     widget.   It then adjusts the view by gain times the dif‐
758                     ference in coordinates, where gain defaults to 10.   This
759                     command  is typically associated with mouse motion events
760                     in the widget, to produce the effect of dragging the can‐
761                     vas  at  high speed through its window.  The return value
762                     is an empty string.
763
764       pathName select option ?tagOrId arg?
765              Manipulates the selection in one of several ways,  depending  on
766              option.   The command may take any of the forms described below.
767              In all of the descriptions below, tagOrId must refer to an  item
768              that  supports indexing and selection;  if it refers to multiple
769              items then the first of these that  supports  indexing  and  the
770              selection is used.  Index gives a textual description of a posi‐
771              tion within tagOrId, as described in INDICES above.
772
773              pathName select adjust tagOrId index
774                     Locate the end of the selection in tagOrId nearest to the
775                     character  given  by  index,  and  adjust that end of the
776                     selection to be at index (i.e. including  but  not  going
777                     beyond  index).   The  other end of the selection is made
778                     the anchor point for future select to commands.   If  the
779                     selection  isn't  currently  in tagOrId then this command
780                     behaves  the  same  as  the  select  to  widget  command.
781                     Returns an empty string.
782
783              pathName select clear
784                     Clear  the  selection  if  it  is in this widget.  If the
785                     selection isn't in this widget then the  command  has  no
786                     effect.  Returns an empty string.
787
788              pathName select from tagOrId index
789                     Set  the selection anchor point for the widget to be just
790                     before the character given by index in the item given  by
791                     tagOrId.   This command doesn't change the selection;  it
792                     just sets the fixed  end  of  the  selection  for  future
793                     select to commands.  Returns an empty string.
794
795              pathName select item
796                     Returns  the id of the selected item, if the selection is
797                     in an item in this canvas.  If the selection  is  not  in
798                     this canvas then an empty string is returned.
799
800              pathName select to tagOrId index
801                     Set  the  selection  to  consist  of  those characters of
802                     tagOrId between the selection  anchor  point  and  index.
803                     The  new  selection  will  include the character given by
804                     index; it will include the character given by the  anchor
805                     point  only  if  index  is  greater  than or equal to the
806                     anchor point.  The anchor point is determined by the most
807                     recent select adjust or select from command for this wid‐
808                     get.  If the selection anchor point for the widget  isn't
809                     currently  in tagOrId, then it is set to the same charac‐
810                     ter given by index.  Returns an empty string.
811
812       pathName type tagOrId
813              Returns the type of the item given by tagOrId, such as rectangle
814              or text.  If tagOrId refers to more than one item, then the type
815              of the first item in the display list is returned.   If  tagOrId
816              doesn't  refer  to  any  items  at  all  then an empty string is
817              returned.
818
819       pathName xview  ?args?
820              This command is used to query and change the horizontal position
821              of  the  information  displayed  in the canvas's window.  It can
822              take any of the following forms:
823
824              pathName xview
825                     Returns a list containing two elements.  Each element  is
826                     a  real fraction between 0 and 1;  together they describe
827                     the horizontal span that is visible in the  window.   For
828                     example,  if  the first element is .2 and the second ele‐
829                     ment is .6, 20% of the canvas's area (as defined  by  the
830                     -scrollregion option) is off-screen to the left, the mid‐
831                     dle 40% is visible in the window, and 40% of  the  canvas
832                     is  off-screen  to  the right.  These are the same values
833                     passed to scrollbars via the -xscrollcommand option.
834
835              pathName xview moveto fraction
836                     Adjusts the view in the window so that  fraction  of  the
837                     total  width  of  the  canvas  is off-screen to the left.
838                     Fraction must be a fraction between 0 and 1.
839
840              pathName xview scroll number what
841                     This command shifts the view in the window left or  right
842                     according to number and what.  Number must be an integer.
843                     What must be either units or pages or an abbreviation  of
844                     one of these.  If what is units, the view adjusts left or
845                     right in units of the xScrollIncrement option, if  it  is
846                     greater  than zero, or in units of one-tenth the window's
847                     width otherwise.  If what is pages then the view  adjusts
848                     in units of nine-tenths the window's width.  If number is
849                     negative then information farther  to  the  left  becomes
850                     visible;   if  it is positive then information farther to
851                     the right becomes visible.
852
853       pathName yview ?args?
854              This command is used to query and change the  vertical  position
855              of  the  information  displayed  in the canvas's window.  It can
856              take any of the following forms:
857
858              pathName yview
859                     Returns a list containing two elements.  Each element  is
860                     a  real fraction between 0 and 1;  together they describe
861                     the vertical span that is visible  in  the  window.   For
862                     example,  if  the first element is .6 and the second ele‐
863                     ment is 1.0, the lowest 40%  of  the  canvas's  area  (as
864                     defined  by  the  -scrollregion option) is visible in the
865                     window.  These are the same values passed  to  scrollbars
866                     via the -yscrollcommand option.
867
868              pathName yview moveto fraction
869                     Adjusts  the  view  in the window so that fraction of the
870                     canvas's area is off-screen to the top.   Fraction  is  a
871                     fraction between 0 and 1.
872
873              pathName yview scroll number what
874                     This  command  adjusts  the view in the window up or down
875                     according to number and what.  Number must be an integer.
876                     What  must  be  either units or pages.  If what is units,
877                     the view adjusts up or down in units of the yScrollIncre‐
878                     ment  option,  if it is greater than zero, or in units of
879                     one-tenth the window's  height  otherwise.   If  what  is
880                     pages  then  the view adjusts in units of nine-tenths the
881                     window's height.   If  number  is  negative  then  higher
882                     information  becomes  visible;   if  it  is positive then
883                     lower information becomes visible.
884

OVERVIEW OF ITEM TYPES

886       The sections below describe the various types  of  items  supported  by
887       canvas  widgets.  Each item type is characterized by two things: first,
888       the form of the create command used to create instances  of  the  type;
889       and  second,  a  set  of  configuration options for items of that type,
890       which may be used in the  create  and  itemconfigure  widget  commands.
891       Most  items don't support indexing or selection or the commands related
892       to them, such as index and insert.  Where items do support these facil‐
893       ities,  it  is noted explicitly in the descriptions below.  At present,
894       text, line and polygon items provide this support.  For lines and poly‐
895       gons the indexing facility is used to manipulate the coordinates of the
896       item.
897

COMMON ITEM OPTIONS

899       Many items share a common set of options.  These options are  explained
900       here, and then referred to be each widget type for brevity.
901
902       -dash pattern
903
904       -activedash pattern
905
906       -disableddash pattern
907              This  option  specifies  dash  patterns  for  the normal, active
908              state, and disabled state of an item.  pattern may have  any  of
909              the forms accepted by Tk_GetDash.  If the dash options are omit‐
910              ted then the default is a solid outline.   See  "DASH  PATTERNS"
911              for more information.
912
913       -dashoffset offset
914              The  starting  offset in pixels into the pattern provided by the
915              -dash option.  -dashoffset is ignored if there is no -dash  pat‐
916              tern.   The  offset  may  have any of the forms described in the
917              COORDINATES section above.
918
919       -fill color
920
921       -activefill color
922
923       -disabledfill color
924              Specifies the color to be used to fill item's area.  in its nor‐
925              mal,  active,  and  disabled  states,  Color may have any of the
926              forms accepted by Tk_GetColor.  If color is an empty string (the
927              default),  then the item will not be filled.  For the line item,
928              it specifies the color of the line drawn.  For the text item, it
929              specifies the foreground color of the text.
930
931       -outline color
932
933       -activeoutline color
934
935       -disabledoutline color
936              This  option specifies the color that should be used to draw the
937              outline of the item in its normal, active and  disabled  states.
938              Color  may  have any of the forms accepted by Tk_GetColor.  This
939              option defaults to black.  If color is  specified  as  an  empty
940              string then no outline is drawn for the item.
941
942       -offset offset
943              Specifies  the  offset  of stipples.  The offset value can be of
944              the form x,y or side, where side can be n, ne, e, se, s, sw,  w,
945              nw, or center. In the first case the origin is the origin of the
946              toplevel of the current window.  For the canvas itself and  can‐
947              vas  objects  the  origin is the canvas origin, but putting # in
948              front of the coordinate pair indicates using the toplevel origin
949              instead.  For  canvas  objects,  the  -offset option is used for
950              stippling as well.  For the line and polygon  canvas  items  you
951              can  also specify an index as argument, which connects the stip‐
952              ple origin to one of the coordinate points of the line/polygon.
953
954       -outlinestipple bitmap
955
956       -activeoutlinestipple bitmap
957
958       -disabledoutlinestipple bitmap
959              This option specifies stipple patterns that should  be  used  to
960              draw  the outline of the item in its normal, active and disabled
961              states.  Indicates that the outline for the item should be drawn
962              with  a stipple pattern; bitmap specifies the stipple pattern to
963              use, in any of the forms accepted by Tk_GetBitmap.  If the -out‐
964              line  option  hasn't  been  specified  then  this  option has no
965              effect.  If bitmap is an empty string (the  default),  then  the
966              outline is drawn in a solid fashion.  Note that stipples are not
967              well supported on platforms that do not use X11 as their drawing
968              API.
969
970       -stipple bitmap
971
972       -activestipple bitmap
973
974       -disabledstipple bitmap
975              This  option  specifies  stipple patterns that should be used to
976              fill the item in its normal, active and disabled states.  bitmap
977              specifies  the  stipple  pattern  to  use,  in  any of the forms
978              accepted by Tk_GetBitmap.  If the -fill option hasn't been spec‐
979              ified  then  this  option  has no effect.  If bitmap is an empty
980              string (the default), then filling is done in a  solid  fashion.
981              For  the text item, it affects the actual text.  Note that stip‐
982              ples are not well supported on platforms that do not use X11  as
983              their drawing API.
984
985       -state state
986              This allows an item to override the canvas widget's global state
987              option.  It takes the same values: normal, disabled or hidden.
988
989       -tags tagList
990              Specifies a set of tags to apply to the item.  TagList  consists
991              of  a list of tag names, which replace any existing tags for the
992              item.  TagList may be an empty list.
993
994       -width outlineWidth
995
996       -activewidth outlineWidth
997
998       -disabledwidth outlineWidth
999              Specifies the width of the outline to be drawn around the item's
1000              region, in its normal, active and disabled states.  outlineWidth
1001              may be in any of the forms described in the COORDINATES  section
1002              above.   If  the  -outline option has been specified as an empty
1003              string then this option has no effect.  This option defaults  to
1004              1.0.   For  arcs,  wide  outlines  will be drawn centered on the
1005              edges of the arc's region.
1006

ARC ITEMS

1008       Items of type arc appear on the display as arc-shaped regions.  An  arc
1009       is  a  section  of  an  oval  delimited by two angles (specified by the
1010       -start and -extent options) and displayed in one of several ways (spec‐
1011       ified  by the -style option).  Arcs are created with widget commands of
1012       the following form:
1013              pathName create arc x1 y1 x2 y2 ?option value option value ...?
1014              pathName create arc coordList ?option value option value ...?
1015       The arguments x1, y1, x2, and y2 or coordList give the  coordinates  of
1016       two  diagonally  opposite corners of a rectangular region enclosing the
1017       oval that defines the arc.  After the coordinates there may be any num‐
1018       ber  of option-value pairs, each of which sets one of the configuration
1019       options for the item.  These same option-value pairs  may  be  used  in
1020       itemconfigure widget commands to change the item's configuration.
1021       The following standard options are supported by arcs:
1022              -dash
1023              -activedash
1024              -disableddash
1025              -dashoffset
1026              -fill
1027              -activefill
1028              -disabledfill
1029              -offset
1030              -outline
1031              -activeoutline
1032              -disabledoutline
1033              -outlinestipple
1034              -activeoutlinestipple
1035              -disabledoutlinestipple
1036              -stipple
1037              -activestipple
1038              -disabledstipple
1039              -state
1040              -tags
1041              -width
1042              -activewidth
1043              -disabledwidth
1044       The following extra options are supported for arcs:
1045
1046       -extent degrees
1047              Specifies  the  size  of  the angular range occupied by the arc.
1048              The arc's range extends for  degrees  degrees  counter-clockwise
1049              from the starting angle given by the -start option.  Degrees may
1050              be negative.  If it is greater than 360 or less than -360,  then
1051              degrees modulo 360 is used as the extent.
1052
1053       -start degrees
1054              Specifies  the  beginning  of  the angular range occupied by the
1055              arc.  Degrees is given in units  of  degrees  measured  counter-
1056              clockwise  from  the 3-o'clock position;  it may be either posi‐
1057              tive or negative.
1058
1059       -style type
1060              Specifies how to  draw  the  arc.   If  type  is  pieslice  (the
1061              default)  then  the  arc's region is defined by a section of the
1062              oval's perimeter plus two line segments, one between the  center
1063              of  the  oval and each end of the perimeter section.  If type is
1064              chord then the arc's region is  defined  by  a  section  of  the
1065              oval's  perimeter  plus a single line segment connecting the two
1066              end points of the perimeter section.  If type is  arc  then  the
1067              arc's  region  consists of a section of the perimeter alone.  In
1068              this last case the -fill option is ignored.
1069

BITMAP ITEMS

1071       Items of type bitmap appear on the display as images with  two  colors,
1072       foreground and background.  Bitmaps are created with widget commands of
1073       the following form:
1074              pathName create bitmap x y ?option value option value ...?
1075              pathName create bitmap coordList ?option value option value ...?
1076       The arguments x and y or coordList specify the coordinates of  a  point
1077       used  to  position  the  bitmap  on the display (see the -anchor option
1078       below for more information on how bitmaps are  displayed).   After  the
1079       coordinates  there  may  be  any  number of option-value pairs, each of
1080       which sets one of the configuration options for the item.   These  same
1081       option-value  pairs  may  be  used  in itemconfigure widget commands to
1082       change the item's configuration.
1083       The following standard options are supported by bitmaps:
1084              -state
1085              -tags
1086       The following extra options are supported for bitmaps:
1087
1088       -anchor anchorPos
1089              AnchorPos tells how to position the bitmap relative to the posi‐
1090              tioning  point  for  the  item;   it  may  have any of the forms
1091              accepted by Tk_GetAnchor.  For example, if anchorPos  is  center
1092              then  the  bitmap  is  centered on the point;  if anchorPos is n
1093              then the bitmap will be drawn so that its top center point is at
1094              the positioning point.  This option defaults to center.
1095
1096       -background color
1097
1098       -activebackground bitmap
1099
1100       -disabledbackground bitmap
1101              Specifies  the  color to use for each of the bitmap's '0' valued
1102              pixels in its normal, active and  disabled  states.   Color  may
1103              have  any  of the forms accepted by Tk_GetColor.  If this option
1104              isn't specified, or if it is specified as an empty string,  then
1105              nothing  is  displayed where the bitmap pixels are 0;  this pro‐
1106              duces a transparent effect.
1107
1108       -bitmap bitmap
1109
1110       -activebitmap bitmap
1111
1112       -disabledbitmap bitmap
1113              Specifies the bitmaps to display in  the  item  in  its  normal,
1114              active  and  disabled  states.  Bitmap may have any of the forms
1115              accepted by Tk_GetBitmap.
1116
1117       -foreground color
1118
1119       -activeforeground bitmap
1120
1121       -disabledforeground bitmap
1122              Specifies the color to use for each of the bitmap's  '1'  valued
1123              pixels  in  its  normal,  active and disabled states.  Color may
1124              have any of the forms accepted by Tk_GetColor  and  defaults  to
1125              black.
1126

IMAGE ITEMS

1128       Items of type image are used to display images on a canvas.  Images are
1129       created with widget commands of the following form:
1130              pathName create image x y ?option value option value ...?
1131              pathName create image coordList ?option value option value ...?
1132       The arguments x and y or coordList specify the coordinates of  a  point
1133       used to position the image on the display (see the -anchor option below
1134       for more information).  After the coordinates there may be  any  number
1135       of  option-value  pairs,  each  of  which sets one of the configuration
1136       options for the item.  These same option-value pairs  may  be  used  in
1137       itemconfigure widget commands to change the item's configuration.
1138       The following standard options are supported by images:
1139              -state
1140              -tags
1141       The following extra options are supported for images:
1142
1143       -anchor anchorPos
1144              AnchorPos  tells how to position the image relative to the posi‐
1145              tioning point for the item;   it  may  have  any  of  the  forms
1146              accepted  by  Tk_GetAnchor.  For example, if anchorPos is center
1147              then the image is centered on the point;  if anchorPos is n then
1148              the  image  will be drawn so that its top center point is at the
1149              positioning point.  This option defaults to center.
1150
1151       -image name
1152
1153       -activeimage name
1154
1155       -disabledimage name
1156              Specifies the name of the images to display in the  item  in  is
1157              normal,  active  and disabled states.  This image must have been
1158              created previously with the image create command.
1159

LINE ITEMS

1161       Items of type line appear on the display as one or more connected  line
1162       segments  or curves.  Line items support coordinate indexing operations
1163       using the canvas widget commands: dchars,  index,  insert.   Lines  are
1164       created with widget commands of the following form:
1165              pathName create line x1 y1... xn yn ?option value option value ...?
1166              pathName create line coordList ?option value option value ...?
1167       The  arguments  x1  through  yn or coordList give the coordinates for a
1168       series of two or more points that describe a series of  connected  line
1169       segments.    After   the   coordinates  there  may  be  any  number  of
1170       option-value pairs, each of which sets one of the configuration options
1171       for the item.  These same option-value pairs may be used in itemconfig‐
1172       ure widget commands to change the item's configuration.
1173       The following standard options are supported by lines:
1174              -dash
1175              -activedash
1176              -disableddash
1177              -dashoffset
1178              -fill
1179              -activefill
1180              -disabledfill
1181              -stipple
1182              -activestipple
1183              -disabledstipple
1184              -state
1185              -tags
1186              -width
1187              -activewidth
1188              -disabledwidth
1189       The following extra options are supported for lines:
1190
1191       -arrow where
1192              Indicates whether or not arrowheads are to be drawn  at  one  or
1193              both  ends  of the line.  Where must have one of the values none
1194              (for no arrowheads), first (for an arrowhead at the first  point
1195              of  the  line),  last (for an arrowhead at the last point of the
1196              line), or both (for  arrowheads  at  both  ends).   This  option
1197              defaults to none.
1198
1199       -arrowshape shape
1200              This  option  indicates how to draw arrowheads.  The shape argu‐
1201              ment must be a list with three elements, each specifying a  dis‐
1202              tance  in  any of the forms described in the COORDINATES section
1203              above.  The first element of the list gives the  distance  along
1204              the  line from the neck of the arrowhead to its tip.  The second
1205              element gives the distance along  the  line  from  the  trailing
1206              points  of the arrowhead to the tip, and the third element gives
1207              the distance from the outside edge of the line to  the  trailing
1208              points.   If  this option isn't specified then Tk picks a ``rea‐
1209              sonable'' shape.
1210
1211       -capstyle style
1212              Specifies the ways in which caps are to be  drawn  at  the  end‐
1213              points of the line.  Style may have any of the forms accepted by
1214              Tk_GetCapStyle (butt, projecting, or  round).   If  this  option
1215              isn't  specified then it defaults to butt.  Where arrowheads are
1216              drawn the cap style is ignored.
1217
1218       -joinstyle style
1219              Specifies the ways in which joints are to be drawn at  the  ver‐
1220              tices  of the line.  Style may have any of the forms accepted by
1221              Tk_GetCapStyle (bevel, miter, or round).  If this  option  isn't
1222              specified  then it defaults to miter.  If the line only contains
1223              two points then this option is irrelevant.
1224
1225       -smooth smoothMethod
1226              smoothMethod must have one of the  forms  accepted  by  Tcl_Get‐
1227              Boolean or a line smoothing method.  Only bezier is supported in
1228              the core, but more can be added at runtime.  If a boolean  false
1229              value  or  empty  string  is  given, no smoothing is applied.  A
1230              boolean truth  value  assume  bezier  smoothing.   It  indicates
1231              whether  or not the line should be drawn as a curve.  If so, the
1232              line is rendered as a set of parabolic splines:  one  spline  is
1233              drawn for the first and second line segments, one for the second
1234              and third, and so on.  Straight-line segments can  be  generated
1235              within a curve by duplicating the end-points of the desired line
1236              segment.
1237
1238       -splinesteps number
1239              Specifies the degree of smoothness  desired  for  curves:   each
1240              spline  will  be  approximated  with number line segments.  This
1241              option is ignored unless the -smooth option is true.
1242
1243

OVAL ITEMS

1245       Items of type oval appear as circular or oval regions on  the  display.
1246       Each oval may have an outline, a fill, or both.  Ovals are created with
1247       widget commands of the following form:
1248              pathName create oval x1 y1 x2 y2 ?option value option value ...?
1249              pathName create oval coordList ?option value option value ...?
1250       The arguments x1, y1, x2, and y2 or coordList give the  coordinates  of
1251       two  diagonally  opposite corners of a rectangular region enclosing the
1252       oval.  The oval will include the top and left edges  of  the  rectangle
1253       not the lower or right edges.  If the region is square then the result‐
1254       ing oval is circular; otherwise it is elongated in  shape.   After  the
1255       coordinates  there  may  be  any  number of option-value pairs, each of
1256       which sets one of the configuration options for the item.   These  same
1257       option-value  pairs  may  be  used  in itemconfigure widget commands to
1258       change the item's configuration.
1259       The following standard options are supported by ovals:
1260              -dash
1261              -activedash
1262              -disableddash
1263              -dashoffset
1264              -fill
1265              -activefill
1266              -disabledfill
1267              -offset
1268              -outline
1269              -activeoutline
1270              -disabledoutline
1271              -outlinestipple
1272              -activeoutlinestipple
1273              -disabledoutlinestipple
1274              -stipple
1275              -activestipple
1276              -disabledstipple
1277              -state
1278              -tags
1279              -width
1280              -activewidth
1281              -disabledwidth
1282

POLYGON ITEMS

1284       Items of type polygon appear as polygonal or curved filled  regions  on
1285       the  display.   Polygon  items  support  coordinate indexing operations
1286       using the canvas widget commands: dchars, index, insert.  Polygons  are
1287       created with widget commands of the following form:
1288              pathName create polygon x1 y1 ... xn yn ?option value option value ...?
1289              pathName create polygon coordList ?option value option value ...?
1290       The  arguments  x1  through yn or coordList specify the coordinates for
1291       three or more points that define a polygon.  The first point should not
1292       be repeated as the last to close the shape; Tk will automatically close
1293       the periphery between the first and last points.  After the coordinates
1294       there  may  be any number of option-value pairs, each of which sets one
1295       of the configuration options for the  item.   These  same  option-value
1296       pairs may be used in itemconfigure widget commands to change the item's
1297       configuration.
1298       The following standard options are supported by polygons:
1299              -dash
1300              -activedash
1301              -disableddash
1302              -dashoffset
1303              -fill
1304              -activefill
1305              -disabledfill
1306              -offset
1307              -outline
1308              -activeoutline
1309              -disabledoutline
1310              -outlinestipple
1311              -activeoutlinestipple
1312              -disabledoutlinestipple
1313              -stipple
1314              -activestipple
1315              -disabledstipple
1316              -state
1317              -tags
1318              -width
1319              -activewidth
1320              -disabledwidth
1321       The following extra options are supported for polygons:
1322
1323       -joinstyle style
1324              Specifies the ways in which joints are to be drawn at  the  ver‐
1325              tices  of the outline.  Style may have any of the forms accepted
1326              by Tk_GetCapStyle (bevel, miter,  or  round).   If  this  option
1327              isn't specified then it defaults to miter.
1328
1329       -smooth boolean
1330              Boolean  must  have one of the forms accepted by Tcl_GetBoolean.
1331              It indicates whether or not the polygon should be drawn  with  a
1332              curved  perimeter.   If so, the outline of the polygon becomes a
1333              set of parabolic splines, one spline for the  first  and  second
1334              line  segments,  one  for  the  second  and  third,  and  so on.
1335              Straight-line segments can be generated in a smoothed polygon by
1336              duplicating the end-points of the desired line segment.
1337
1338       -splinesteps number
1339              Specifies  the  degree  of  smoothness desired for curves:  each
1340              spline will be approximated with  number  line  segments.   This
1341              option is ignored unless the -smooth option is true.
1342
1343       Polygon  items are different from other items such as rectangles, ovals
1344       and arcs in that interior points are  considered  to  be  ``inside''  a
1345       polygon  (e.g.  for  purposes  of the find closest and find overlapping
1346       widget commands) even if it is not filled.  For most other item  types,
1347       an  interior point is considered to be inside the item only if the item
1348       is filled or if it has neither a fill nor an  outline.   If  you  would
1349       like an unfilled polygon whose interior points are not considered to be
1350       inside the polygon, use a line item instead.
1351

RECTANGLE ITEMS

1353       Items of type rectangle appear as rectangular regions on  the  display.
1354       Each  rectangle  may  have an outline, a fill, or both.  Rectangles are
1355       created with widget commands of the following form:
1356              pathName create rectangle x1 y1 x2 y2 ?option value option value ...?
1357              pathName create rectangle coordList ?option value option value ...?
1358       The arguments x1, y1, x2, and y2 or coordList give the  coordinates  of
1359       two  diagonally  opposite  corners of the rectangle (the rectangle will
1360       include its upper and left edges but not its  lower  or  right  edges).
1361       After  the  coordinates  there may be any number of option-value pairs,
1362       each of which sets one of  the  configuration  options  for  the  item.
1363       These  same option-value pairs may be used in itemconfigure widget com‐
1364       mands to change the item's configuration.
1365       The following standard options are supported by rectangles:
1366              -dash
1367              -activedash
1368              -disableddash
1369              -dashoffset
1370              -fill
1371              -activefill
1372              -disabledfill
1373              -offset
1374              -outline
1375              -activeoutline
1376              -disabledoutline
1377              -outlinestipple
1378              -activeoutlinestipple
1379              -disabledoutlinestipple
1380              -stipple
1381              -activestipple
1382              -disabledstipple
1383              -state
1384              -tags
1385              -width
1386              -activewidth
1387              -disabledwidth
1388

TEXT ITEMS

1390       A text item displays a string of characters on the  screen  in  one  or
1391       more  lines.  Text items support indexing and selection, along with the
1392       following text-related canvas widget commands:  dchars, focus, icursor,
1393       index,  insert, select.  Text items are created with widget commands of
1394       the following form:
1395              pathName create text x y ?option value option value ...?
1396              pathName create text coordList ?option value option value ...?
1397       The arguments x and y or coordList specify the coordinates of  a  point
1398       used  to  position  the  text on the display (see the options below for
1399       more information on how text  is  displayed).   After  the  coordinates
1400       there  may  be any number of option-value pairs, each of which sets one
1401       of the configuration options for the  item.   These  same  option-value
1402       pairs may be used in itemconfigure widget commands to change the item's
1403       configuration.
1404       The following standard options are supported by text items:
1405              -fill
1406              -activefill
1407              -disabledfill
1408              -stipple
1409              -activestipple
1410              -disabledstipple
1411              -state
1412              -tags
1413       The following extra options are supported for text items:
1414
1415       -anchor anchorPos
1416              AnchorPos tells how to position the text relative to  the  posi‐
1417              tioning  point  for  the  text;   it  may  have any of the forms
1418              accepted by Tk_GetAnchor.  For example, if anchorPos  is  center
1419              then  the text is centered on the point;  if anchorPos is n then
1420              the text will be drawn such that the top  center  point  of  the
1421              rectangular region occupied by the text will be at the position‐
1422              ing point.  This option defaults to center.
1423
1424       -font fontName
1425              Specifies the font to use for the text item.   FontName  may  be
1426              any string acceptable to Tk_GetFont.  If this option isn't spec‐
1427              ified, it defaults to a system-dependent font.
1428
1429       -justify how
1430              Specifies how to justify the text within  its  bounding  region.
1431              How  must  be  one  of  the values left, right, or center.  This
1432              option will only matter if the text  is  displayed  as  multiple
1433              lines.  If the option is omitted, it defaults to left.
1434
1435       -text string
1436              String  specifies  the  characters  to  be displayed in the text
1437              item.  Newline characters cause line breaks.  The characters  in
1438              the  item  may also be changed with the insert and delete widget
1439              commands.  This option defaults to an empty string.
1440
1441       -width lineLength
1442              Specifies a maximum line length for the  text,  in  any  of  the
1443              forms  described  in  the  COORDINATES  section  above.  If this
1444              option is zero (the default) the text is broken into lines  only
1445              at newline characters.  However, if this option is non-zero then
1446              any line that would be longer than  lineLength  is  broken  just
1447              before  a  space  character  to make the line shorter than line‐
1448              Length;  the space character is treated as if it were a  newline
1449              character.
1450

WINDOW ITEMS

1452       Items  of  type  window  cause a particular window to be displayed at a
1453       given position on the canvas.  Window items  are  created  with  widget
1454       commands of the following form:
1455              pathName create window x y ?option value option value ...?
1456              pathName create window coordList ?option value option value ...?
1457       The  arguments  x and y or coordList specify the coordinates of a point
1458       used to position the window on the  display  (see  the  -anchor  option
1459       below  for  more  information on how bitmaps are displayed).  After the
1460       coordinates there may be any number  of  option-value  pairs,  each  of
1461       which  sets  one of the configuration options for the item.  These same
1462       option-value pairs may be used  in  itemconfigure  widget  commands  to
1463       change the item's configuration.
1464       The following standard options are supported by window items:
1465              -state
1466              -tags
1467       The following extra options are supported for window items:
1468
1469       -anchor anchorPos
1470              AnchorPos tells how to position the window relative to the posi‐
1471              tioning point for the item;   it  may  have  any  of  the  forms
1472              accepted  by  Tk_GetAnchor.  For example, if anchorPos is center
1473              then the window is centered on the point;   if  anchorPos  is  n
1474              then the window will be drawn so that its top center point is at
1475              the positioning point.  This option defaults to center.
1476
1477       -height pixels
1478              Specifies the height to assign to the item's window.  Pixels may
1479              have  any  of  the  forms  described  in the COORDINATES section
1480              above.  If this option isn't specified, or if it is specified as
1481              an  empty  string,  then  the window is given whatever height it
1482              requests internally.
1483
1484       -width pixels
1485              Specifies the width to assign to the item's window.  Pixels  may
1486              have  any  of  the  forms  described  in the COORDINATES section
1487              above.  If this option isn't specified, or if it is specified as
1488              an  empty  string,  then  the  window is given whatever width it
1489              requests internally.
1490
1491       -window pathName
1492              Specifies the window to associate with this  item.   The  window
1493              specified  by pathName must either be a child of the canvas wid‐
1494              get or a child of some ancestor of the canvas widget.   PathName
1495              may not refer to a top-level window.
1496
1497       Note:   due to restrictions in the ways that windows are managed, it is
1498       not possible to draw other graphical items (such as lines  and  images)
1499       on  top  of  window  items.  A window item always obscures any graphics
1500       that overlap it, regardless of their order in the display list.
1501

APPLICATION-DEFINED ITEM TYPES

1503       It is possible for individual applications to define new item types for
1504       canvas  widgets using C code.  See the documentation for Tk_CreateItem‐
1505       Type.
1506

BINDINGS

1508       In the current implementation, new canvases are not given  any  default
1509       behavior:   you'll  have  to  execute explicit Tcl commands to give the
1510       canvas its behavior.
1511

CREDITS

1513       Tk's canvas widget is a blatant ripoff of ideas  from  Joel  Bartlett's
1514       ezd  program.  Ezd provides structured graphics in a Scheme environment
1515       and preceded canvases by a year or  two.   Its  simple  mechanisms  for
1516       placing  and animating graphical objects inspired the functions of can‐
1517       vases.
1518
1519

SEE ALSO

1521       bind(n), font(n), image(n), scrollbar(n)
1522
1523

KEYWORDS

1525       canvas, widget
1526
1527
1528
1529Tk                                    8.3                            canvas(n)
Impressum