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           -borderwidth         -cursor
15       -highlightbackground  -highlightcolor      -highlightthickness
16       -insertbackground     -insertborderwidth   -insertofftime
17       -insertontime         -insertwidth         -relief
18       -selectbackground     -selectborderwidth   -selectforeground
19       -takefocus            -xscrollcommand      -yscrollcommand
20
21       See the options manual entry for details on the standard options.
22

WIDGET-SPECIFIC OPTIONS

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

INTRODUCTION

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

DISPLAY LIST

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

ITEM IDS AND TAGS

107       Items in a canvas widget may be named in either of two ways: by  id  or
108       by  tag.   Each item has a unique identifying number, which is assigned
109       to that item when it is created.  The id of an item never  changes  and
110       id numbers are never re-used within the lifetime of a canvas widget.
111
112       Each  item  may also have any number of tags associated with it.  A tag
113       is just a string of characters, and it may take any form except that of
114       an  integer.  For example, “x123” is OK but “123” is not.  The same tag
115       may be associated with many different items.  This is commonly done  to
116       group  items  in  various  interesting ways;  for example, all selected
117       items might be given the tag “selected”.
118
119       The tag all is implicitly associated with every item in the canvas;  it
120       may be used to invoke operations on all the items in the canvas.
121
122       The  tag current is managed automatically by Tk; it applies to the cur‐
123       rent item, which is the topmost item whose drawn area covers the  posi‐
124       tion  of the mouse cursor (different item types interpret this in vary‐
125       ing ways; see the individual item type documentation for details).   If
126       the  mouse  is not in the canvas widget or is not over an item, then no
127       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
163   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 do not support the insertion cur‐
198       sor 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 is not 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 is not 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 cannot 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  “.”
254       will  always  be displayed as a dot and “-” always as a dash regardless
255       of the 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 is not 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  the
329              named  elements are within the region bounded by x1 on the left,
330              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 com‐
347              mand augments an existing binding rather than replacing it).  In
348              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 do not support indexing oper‐
442              ations 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 does not 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 does not refer to  any  items,
471              or  if none of them support the insertion cursor, then the focus
472              is not 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 does not 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 was not 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 does not 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  do  not
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  does  not  have  the  focus.   This  command
505              returns 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 reach
597              its final size, or else use the -width and  -height  options  to
598              specify the area of the canvas to print.  The option-value argu‐
599              ment pairs provide additional information to control the genera‐
600              tion 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 setrgbcolor”).
607                     When  outputting  color information in the Postscript, Tk
608                     checks to see if there is an element of varName with  the
609                     same  name as the color.  If so, Tk uses the value of the
610                     element as the Postscript command to set the  color.   If
611                     this  option  has  not  been specified, or if there is no
612                     entry in varName for a given color, then Tk uses the red,
613                     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  is not 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  is  not 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 is not 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 does not 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 is not
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              does  not  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 do not 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
898   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  for
911              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  has  not  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       -outlineoffset offset
971              Specifies  the  offset of the stipple pattern used for outlines.
972              The offset value can be of the form “x,y” or the description  of
973              a  side  (one  of  n,  ne, e, se, s, sw, w, nw, or center). This
974              option only has an effect when the outline is drawn as a stipple
975              pattern, and is only supported under X11.
976
977       -stipple bitmap
978
979       -activestipple bitmap
980
981       -disabledstipple bitmap
982              This  option  specifies  stipple patterns that should be used to
983              fill the item in its normal, active and disabled states.  bitmap
984              specifies  the  stipple  pattern  to  use,  in  any of the forms
985              accepted by Tk_GetBitmap.  If the  -fill  option  has  not  been
986              specified then this option has no effect.  If bitmap is an empty
987              string (the default), then filling is done in a  solid  fashion.
988              For  the text item, it affects the actual text.  Note that stip‐
989              ples are not well supported on platforms that do not use X11  as
990              their drawing API.
991
992       -state state
993              This allows an item to override the canvas widget's global state
994              option.  It takes the same values: normal, disabled or hidden.
995
996       -tags tagList
997              Specifies a set of tags to apply to the item.  TagList  consists
998              of  a list of tag names, which replace any existing tags for the
999              item.  TagList may be an empty list.
1000
1001       -width outlineWidth
1002
1003       -activewidth outlineWidth
1004
1005       -disabledwidth outlineWidth
1006              Specifies the width of the outline to be drawn around the item's
1007              region, in its normal, active and disabled states.  outlineWidth
1008              may be in any of the forms described in the COORDINATES  section
1009              above.   If  the  -outline option has been specified as an empty
1010              string then this option has no effect.  This option defaults  to
1011              1.0.   For  arcs,  wide  outlines  will be drawn centered on the
1012              edges of the arc's region.
1013

ARC ITEMS

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

BITMAP ITEMS

1083       Items  of  type bitmap appear on the display as images with two colors,
1084       foreground and background.  Bitmaps are created with widget commands of
1085       the following form:
1086              pathName create bitmap x y ?option value option value ...?
1087              pathName create bitmap coordList ?option value option value ...?
1088       The arguments x and y or coordList (which must have two elements) spec‐
1089       ify the coordinates of a point used to position the bitmap on the  dis‐
1090       play  (see the -anchor option below for more information on how bitmaps
1091       are displayed).  After the coordinates  there  may  be  any  number  of
1092       option-value pairs, each of which sets one of the configuration options
1093       for the item.  These same option-value pairs may be used in itemconfig‐
1094       ure  widget  commands to change the item's configuration. A bitmap item
1095       becomes the current item when the mouse pointer is over any part of its
1096       bounding box.
1097
1098       The following standard options are supported by bitmaps:
1099              -state
1100              -tags
1101       The following extra options are supported for bitmaps:
1102
1103       -anchor anchorPos
1104              AnchorPos tells how to position the bitmap relative to the posi‐
1105              tioning point for the item;   it  may  have  any  of  the  forms
1106              accepted  by  Tk_GetAnchor.  For example, if anchorPos is center
1107              then the bitmap is centered on the point;   if  anchorPos  is  n
1108              then the bitmap will be drawn so that its top center point is at
1109              the positioning point.  This option defaults to center.
1110
1111       -background color
1112
1113       -activebackground color
1114
1115       -disabledbackground color
1116              Specifies the color to use for each of the bitmap's  “0”  valued
1117              pixels  in  its  normal,  active and disabled states.  Color may
1118              have any of the forms accepted by Tk_GetColor.  If  this  option
1119              is not specified, or if it is specified as an empty string, then
1120              nothing is displayed where the bitmap pixels are 0;   this  pro‐
1121              duces a transparent effect.
1122
1123       -bitmap bitmap
1124
1125       -activebitmap bitmap
1126
1127       -disabledbitmap bitmap
1128              Specifies  the  bitmaps  to  display  in the item in its normal,
1129              active and disabled states.  Bitmap may have any  of  the  forms
1130              accepted by Tk_GetBitmap.
1131
1132       -foreground color
1133
1134       -activeforeground color
1135
1136       -disabledforeground color
1137              Specifies  the  color to use for each of the bitmap's “1” valued
1138              pixels in its normal, active and  disabled  states.   Color  may
1139              have  any  of  the forms accepted by Tk_GetColor and defaults to
1140              black.
1141

IMAGE ITEMS

1143       Items of type image are used to display images on a canvas.  Images are
1144       created with widget commands of the following form:
1145              pathName create image x y ?option value option value ...?
1146              pathName create image coordList ?option value option value ...?
1147       The  arguments  x and y or coordList specify the coordinates of a point
1148       used to position the image on the display (see the -anchor option below
1149       for  more  information).  After the coordinates there may be any number
1150       of option-value pairs, each of which  sets  one  of  the  configuration
1151       options  for  the  item.   These same option-value pairs may be used in
1152       itemconfigure widget commands to change the  item's  configuration.  An
1153       image  item becomes the current item when the mouse pointer is over any
1154       part of its bounding box.
1155
1156       The following standard options are supported by images:
1157              -state
1158              -tags
1159       The following extra options are supported for images:
1160
1161       -anchor anchorPos
1162              AnchorPos tells how to position the image relative to the  posi‐
1163              tioning  point  for  the  item;   it  may  have any of the forms
1164              accepted by Tk_GetAnchor.  For example, if anchorPos  is  center
1165              then the image is centered on the point;  if anchorPos is n then
1166              the image will be drawn so that its top center point is  at  the
1167              positioning point.  This option defaults to center.
1168
1169       -image name
1170
1171       -activeimage name
1172
1173       -disabledimage name
1174              Specifies  the  name  of the images to display in the item in is
1175              normal, active and disabled states.  This image must  have  been
1176              created previously with the image create command.
1177

LINE ITEMS

1179       Items  of type line appear on the display as one or more connected line
1180       segments or curves.  Line items support coordinate indexing  operations
1181       using  the  canvas  widget  commands: dchars, index, insert.  Lines are
1182       created with widget commands of the following form:
1183              pathName create line x1 y1... xn yn ?option value option value ...?
1184              pathName create line coordList ?option value option value ...?
1185       The arguments x1 through yn or coordList give  the  coordinates  for  a
1186       series  of  two or more points that describe a series of connected line
1187       segments.   After  the  coordinates  there  may  be   any   number   of
1188       option-value pairs, each of which sets one of the configuration options
1189       for the item.  These same option-value pairs may be used in itemconfig‐
1190       ure  widget commands to change the item's configuration. A line item is
1191       the current item whenever the mouse pointer is over any segment of  the
1192       line, whether drawn or not and whether or not the line is smoothed.
1193
1194       The following standard options are supported by lines:
1195              -dash
1196              -activedash
1197              -disableddash
1198              -dashoffset
1199              -fill
1200              -activefill
1201              -disabledfill
1202              -stipple
1203              -activestipple
1204              -disabledstipple
1205              -state
1206              -tags
1207              -width
1208              -activewidth
1209              -disabledwidth
1210       The following extra options are supported for lines:
1211
1212       -arrow where
1213              Indicates  whether  or  not arrowheads are to be drawn at one or
1214              both ends of the line.  Where must have one of the  values  none
1215              (for  no arrowheads), first (for an arrowhead at the first point
1216              of the line), last (for an arrowhead at the last  point  of  the
1217              line),  or  both  (for  arrowheads  at  both ends).  This option
1218              defaults to none.
1219
1220       -arrowshape shape
1221              This option indicates how to draw arrowheads.  The  shape  argu‐
1222              ment  must be a list with three elements, each specifying a dis‐
1223              tance in any of the forms described in the  COORDINATES  section
1224              above.   The  first element of the list gives the distance along
1225              the line from the neck of the arrowhead to its tip.  The  second
1226              element  gives  the  distance  along  the line from the trailing
1227              points of the arrowhead to the tip, and the third element  gives
1228              the  distance  from the outside edge of the line to the trailing
1229              points.  If this option is not specified then Tk picks  a  “rea‐
1230              sonable” shape.
1231
1232       -capstyle style
1233              Specifies  the  ways  in  which caps are to be drawn at the end‐
1234              points of the line.  Style may have any of the forms accepted by
1235              Tk_GetCapStyle  (butt, projecting, or round).  If this option is
1236              not specified then it defaults to butt.   Where  arrowheads  are
1237              drawn the cap style is ignored.
1238
1239       -joinstyle style
1240              Specifies  the  ways in which joints are to be drawn at the ver‐
1241              tices of the line.  Style may have any of the forms accepted  by
1242              Tk_GetCapStyle  (bevel, miter, or round).  If this option is not
1243              specified then it defaults to round.  If the line only  contains
1244              two points then this option is irrelevant.
1245
1246       -smooth smoothMethod
1247              smoothMethod  must  have  one  of the forms accepted by Tcl_Get‐
1248              Boolean or a line smoothing method.  Only true and raw are  sup‐ │
1249              ported  in  the  core (with bezier being an alias for true), but │
1250              more can be added at runtime.  If a boolean false value or empty │
1251              string is given, no smoothing is applied.  A boolean truth value │
1252              assumes true smoothing.  If the smoothing method is  true,  this │
1253              indicates  that the line should be drawn as a curve, rendered as │
1254              a set of quadratic splines: one spline is drawn  for  the  first │
1255              and  second  line segments, one for the second and third, and so │
1256              on.  Straight-line segments can be generated within a  curve  by │
1257              duplicating  the end-points of the desired line segment.  If the │
1258              smoothing method is raw, this indicates  that  the  line  should │
1259              also  be  drawn  as a curve but where the list of coordinates is │
1260              such that the first coordinate pair (and every third  coordinate │
1261              pair  thereafter)  is  a knot point on a cubic Bezier curve, and │
1262              the other coordinates are control points  on  the  cubic  Bezier │
1263              curve.   Straight  line segments can be generated within a curve │
1264              by making  control  points  equal  to  their  neighbouring  knot │
1265              points.   If  the  last  point is a control point and not a knot │
1266              point, the point is repeated (one or two times) so that it  also │
1267              becomes a knot point.
1268
1269       -splinesteps number
1270              Specifies  the  degree  of  smoothness desired for curves:  each
1271              spline will be approximated with  number  line  segments.   This
1272              option is ignored unless the -smooth option is true or raw.
1273

OVAL ITEMS

1275       Items  of  type oval appear as circular or oval regions on the display.
1276       Each oval may have an outline, a fill, or both.  Ovals are created with
1277       widget commands of the following form:
1278              pathName create oval x1 y1 x2 y2 ?option value option value ...?
1279              pathName create oval coordList ?option value option value ...?
1280       The  arguments  x1, y1, x2, and y2 or coordList give the coordinates of
1281       two diagonally opposite corners of a rectangular region  enclosing  the
1282       oval.   The  oval  will include the top and left edges of the rectangle
1283       not the lower or right edges.  If the region is square then the result‐
1284       ing  oval  is  circular; otherwise it is elongated in shape.  After the
1285       coordinates there may be any number  of  option-value  pairs,  each  of
1286       which  sets  one of the configuration options for the item.  These same
1287       option-value pairs may be used  in  itemconfigure  widget  commands  to
1288       change  the item's configuration. An oval item becomes the current item
1289       when the mouse pointer is over any part that is painted or (when  fully
1290       transparent)  that  would  be  painted  if  both the -fill and -outline
1291       options were non-empty.
1292
1293       The following standard options are supported by ovals:
1294              -dash
1295              -activedash
1296              -disableddash
1297              -dashoffset
1298              -fill
1299              -activefill
1300              -disabledfill
1301              -offset
1302              -outline
1303              -activeoutline
1304              -disabledoutline
1305              -outlineoffset
1306              -outlinestipple
1307              -activeoutlinestipple
1308              -disabledoutlinestipple
1309              -stipple
1310              -activestipple
1311              -disabledstipple
1312              -state
1313              -tags
1314              -width
1315              -activewidth
1316              -disabledwidth
1317

POLYGON ITEMS

1319       Items of type polygon appear as polygonal or curved filled  regions  on
1320       the  display.   Polygon  items  support  coordinate indexing operations
1321       using the canvas widget commands: dchars, index, insert.  Polygons  are
1322       created with widget commands of the following form:
1323              pathName create polygon x1 y1 ... xn yn ?option value option value ...?
1324              pathName create polygon coordList ?option value option value ...?
1325       The  arguments  x1  through yn or coordList specify the coordinates for
1326       three or more points that define a polygon.  The first point should not
1327       be repeated as the last to close the shape; Tk will automatically close
1328       the periphery between the first and last points.  After the coordinates
1329       there  may  be any number of option-value pairs, each of which sets one
1330       of the configuration options for the  item.   These  same  option-value
1331       pairs may be used in itemconfigure widget commands to change the item's
1332       configuration. A polygon item is the current item  whenever  the  mouse
1333       pointer  is  over  any  part  of  the polygon, whether drawn or not and
1334       whether or not the outline is smoothed.
1335
1336       The following standard options are supported by polygons:
1337              -dash
1338              -activedash
1339              -disableddash
1340              -dashoffset
1341              -fill
1342              -activefill
1343              -disabledfill
1344              -offset
1345              -outline
1346              -activeoutline
1347              -disabledoutline
1348              -outlinestipple
1349              -activeoutlinestipple
1350              -disabledoutlinestipple
1351              -stipple
1352              -activestipple
1353              -disabledstipple
1354              -state
1355              -tags
1356              -width
1357              -activewidth
1358              -disabledwidth
1359       The following extra options are supported for polygons:
1360
1361       -joinstyle style
1362              Specifies the ways in which joints are to be drawn at  the  ver‐
1363              tices  of the outline.  Style may have any of the forms accepted
1364              by Tk_GetCapStyle (bevel, miter, or round).  If this  option  is
1365              not specified then it defaults to round.
1366
1367       -smooth boolean
1368              Boolean must have one of the forms accepted by Tcl_GetBoolean or │
1369              a line smoothing method. Only true and raw are supported in  the │
1370              core  (with  bezier  being  an  alias for true), but more can be │
1371              added at runtime.  If a boolean false value or empty  string  is │
1372              given,  no  smoothing is applied.  A boolean truth value assumes │
1373              true smoothing.  If the smoothing method is true, this indicates │
1374              that  the  polygon should be drawn as a curve, rendered as a set │
1375              of quadratic splines: one spline is drawn for the first and sec‐ │
1376              ond  line  segments,  one  for  the second and third, and so on. │
1377              Straight-line segments can be generated within a curve by dupli‐ │
1378              cating  the  end-points  of  the  desired  line segment.  If the │
1379              smoothing method is raw, this indicates that the polygon  should │
1380              also  be  drawn  as a curve but where the list of coordinates is │
1381              such that the first coordinate pair (and every third  coordinate │
1382              pair  thereafter)  is  a knot point on a cubic Bezier curve, and │
1383              the other coordinates are control points  on  the  cubic  Bezier │
1384              curve.   Straight  line segments can be venerated within a curve │
1385              by making  control  points  equal  to  their  neighbouring  knot │
1386              points.   If the last point is not the second point of a pair of │
1387              control points, the point is repeated (one or two times) so that │
1388              it  also  becomes  the  second point of a pair of control points │
1389              (the associated knot point will be the first control point).
1390
1391       -splinesteps number
1392              Specifies the degree of smoothness  desired  for  curves:   each
1393              spline  will  be  approximated  with number line segments.  This
1394              option is ignored unless the -smooth option is true or raw.
1395
1396       Polygon items are different from other items such as rectangles,  ovals
1397       and  arcs in that interior points are considered to be “inside” a poly‐
1398       gon (e.g. for purposes of the find closest and find overlapping  widget
1399       commands)  even  if  it  is  not filled.  For most other item types, an
1400       interior point is considered to be inside the item only if the item  is
1401       filled  or  if it has neither a fill nor an outline.  If you would like
1402       an unfilled polygon whose interior points  are  not  considered  to  be
1403       inside the polygon, use a line item instead.
1404

RECTANGLE ITEMS

1406       Items  of  type rectangle appear as rectangular regions on the display.
1407       Each rectangle may have an outline, a fill, or  both.   Rectangles  are
1408       created with widget commands of the following form:
1409              pathName create rectangle x1 y1 x2 y2 ?option value option value ...?
1410              pathName create rectangle coordList ?option value option value ...?
1411       The  arguments  x1,  y1,  x2, and y2 or coordList (which must have four
1412       elements) give the coordinates of two diagonally  opposite  corners  of
1413       the  rectangle (the rectangle will include its upper and left edges but
1414       not its lower or right edges).  After the coordinates there may be  any
1415       number  of option-value pairs, each of which sets one of the configura‐
1416       tion options for the item.  These same option-value pairs may  be  used
1417       in  itemconfigure widget commands to change the item's configuration. A
1418       rectangle item becomes the current item when the mouse pointer is  over
1419       any  part  that  is  painted  or (when fully transparent) that would be
1420       painted if both the -fill and -outline options were non-empty.
1421
1422       The following standard options are supported by rectangles:
1423              -dash
1424              -activedash
1425              -disableddash
1426              -dashoffset
1427              -fill
1428              -activefill
1429              -disabledfill
1430              -offset
1431              -outline
1432              -activeoutline
1433              -disabledoutline
1434              -outlineoffset
1435              -outlinestipple
1436              -activeoutlinestipple
1437              -disabledoutlinestipple
1438              -stipple
1439              -activestipple
1440              -disabledstipple
1441              -state
1442              -tags
1443              -width
1444              -activewidth
1445              -disabledwidth
1446

TEXT ITEMS

1448       A text item displays a string of characters on the  screen  in  one  or
1449       more  lines.  Text items support indexing and selection, along with the
1450       following text-related canvas widget commands:  dchars, focus, icursor,
1451       index,  insert, select.  Text items are created with widget commands of
1452       the following form:
1453              pathName create text x y ?option value option value ...?
1454              pathName create text coordList ?option value option value ...?
1455       The arguments x and y or coordList (which must have two elements) spec‐
1456       ify the coordinates of a point used to position the text on the display
1457       (see the options below for more information on how text is  displayed).
1458       After  the  coordinates  there may be any number of option-value pairs,
1459       each of which sets one of  the  configuration  options  for  the  item.
1460       These  same option-value pairs may be used in itemconfigure widget com‐
1461       mands to change the item's configuration. A text item becomes the  cur‐
1462       rent item when the mouse pointer is over any part of its bounding box.
1463
1464       The following standard options are supported by text items:
1465              -fill
1466              -activefill
1467              -disabledfill
1468              -stipple
1469              -activestipple
1470              -disabledstipple
1471              -state
1472              -tags
1473       The following extra options are supported for text items:
1474
1475       -anchor anchorPos
1476              AnchorPos  tells  how to position the text relative to the posi‐
1477              tioning point for the text;   it  may  have  any  of  the  forms
1478              accepted  by  Tk_GetAnchor.  For example, if anchorPos is center
1479              then the text is centered on the point;  if anchorPos is n  then
1480              the  text  will  be  drawn such that the top center point of the
1481              rectangular region occupied by the text will be at the position‐
1482              ing point.  This option defaults to center.
1483
1484       -font fontName
1485              Specifies  the  font  to use for the text item.  FontName may be
1486              any string acceptable to Tk_GetFont.   If  this  option  is  not
1487              specified, it defaults to a system-dependent font.
1488
1489       -justify how
1490              Specifies  how  to  justify the text within its bounding region.
1491              How must be one of the values  left,  right,  or  center.   This
1492              option  will  only  matter  if the text is displayed as multiple
1493              lines.  If the option is omitted, it defaults to left.
1494
1495       -text string
1496              String specifies the characters to  be  displayed  in  the  text
1497              item.   Newline characters cause line breaks.  The characters in
1498              the item may also be changed with the insert and  delete  widget
1499              commands.  This option defaults to an empty string.              │
1500
1501       -underline                                                              
1502              Specifies the integer index of a character within the text to be │
1503              underlined. 0 corresponds to the first  character  of  the  text │
1504              displayed,  1 to the next character, and so on. -1 means that no │
1505              underline should be drawn (if the  whole  text  item  is  to  be │
1506              underlined, the appropriate font should be used instead).
1507
1508       -width lineLength
1509              Specifies  a  maximum  line  length  for the text, in any of the
1510              forms described in  the  COORDINATES  section  above.   If  this
1511              option  is zero (the default) the text is broken into lines only
1512              at newline characters.  However, if this option is non-zero then
1513              any  line  that  would  be longer than lineLength is broken just
1514              before a space character to make the  line  shorter  than  line‐
1515              Length;   the space character is treated as if it were a newline
1516              character.
1517

WINDOW ITEMS

1519       Items of type window cause a particular window to  be  displayed  at  a
1520       given  position  on  the  canvas.  Window items are created with widget
1521       commands of the following form:
1522              pathName create window x y ?option value option value ...?
1523              pathName create window coordList ?option value option value ...?
1524       The arguments x and y or coordList (which must have two elements) spec‐
1525       ify  the coordinates of a point used to position the window on the dis‐
1526       play (see the -anchor option below for more information on how  bitmaps
1527       are  displayed).   After  the  coordinates  there  may be any number of
1528       option-value pairs, each of which sets one of the configuration options
1529       for the item.  These same option-value pairs may be used in itemconfig‐
1530       ure widget commands to change the item's configuration.  Theoretically,
1531       a  window  item becomes the current item when the mouse pointer is over
1532       any part of its bounding box, but in practice this typically  does  not
1533       happen  because  the mouse pointer ceases to be over the canvas at that
1534       point.
1535
1536       The following standard options are supported by window items:
1537              -state
1538              -tags
1539       The following extra options are supported for window items:
1540
1541       -anchor anchorPos
1542              AnchorPos tells how to position the window relative to the posi‐
1543              tioning  point  for  the  item;   it  may  have any of the forms
1544              accepted by Tk_GetAnchor.  For example, if anchorPos  is  center
1545              then  the  window  is  centered on the point;  if anchorPos is n
1546              then the window will be drawn so that its top center point is at
1547              the positioning point.  This option defaults to center.
1548
1549       -height pixels
1550              Specifies the height to assign to the item's window.  Pixels may
1551              have any of the  forms  described  in  the  COORDINATES  section
1552              above.   If  this option is not specified, or if it is specified
1553              as zero, then the window is given whatever  height  it  requests
1554              internally.
1555
1556       -width pixels
1557              Specifies  the width to assign to the item's window.  Pixels may
1558              have any of the  forms  described  in  the  COORDINATES  section
1559              above.   If  this option is not specified, or if it is specified
1560              as zero, then the window is given  whatever  width  it  requests
1561              internally.
1562
1563       -window pathName
1564              Specifies  the  window  to associate with this item.  The window
1565              specified by pathName must either be a child of the canvas  wid‐
1566              get  or a child of some ancestor of the canvas widget.  PathName
1567              may not refer to a top-level window.
1568
1569       Note:  due to restrictions in the ways that windows are managed, it  is
1570       not  possible  to draw other graphical items (such as lines and images)
1571       on top of window items.  A window item  always  obscures  any  graphics
1572       that  overlap  it,  regardless of their order in the display list. Also
1573       note that window items, unlike other canvas items, are not clipped  for
1574       display by their containing canvas's border, and are instead clipped by
1575       the parent widget of the window specified by the -window  option;  when
1576       the  parent  widget  is the canvas, this means that the window item can
1577       overlap the canvas's border.
1578

APPLICATION-DEFINED ITEM TYPES

1580       It is possible for individual applications to define new item types for
1581       canvas  widgets using C code.  See the documentation for Tk_CreateItem‐
1582       Type.
1583

BINDINGS

1585       In the current implementation, new canvases are not given  any  default
1586       behavior:   you  will have to execute explicit Tcl commands to give the
1587       canvas its behavior.
1588

CREDITS

1590       Tk's canvas widget is a blatant ripoff of ideas  from  Joel  Bartlett's
1591       ezd  program.  Ezd provides structured graphics in a Scheme environment
1592       and preceded canvases by a year or  two.   Its  simple  mechanisms  for
1593       placing  and animating graphical objects inspired the functions of can‐
1594       vases.
1595

SEE ALSO

1597       bind(n), font(n), image(n), scrollbar(n)
1598

KEYWORDS

1600       canvas, widget
1601
1602
1603
1604Tk                                    8.3                            canvas(n)
Impressum