PyDocs

Nav

Graphical user interfaces with Tk

Canvas

tkinter

class
  • Canvas(master=None, cnf={}, **kw)
A Canvas widget implements structured graphics. It displays any number of items, such as arcs, lines, ovals, polygons, rectangles, text, bitmaps, images and embedded windows, which may be drawn, moved, re-colored and bound to events. Inherits from Widget, XView and YView, so the view can be scrolled horizontally and vertically with xview() and yview(). Refer to the Tk canvas manual page for the full list of widget and item options.
Members of Canvas

a

addtag
Add the tag newtag to each item selected by the search specification searchSpec (and any further args).
addtag_above
Add the tag newtag to the item just above (after) tagOrId in the display list.
addtag_all
Add the tag newtag to all items in the canvas.
addtag_below
Add the tag newtag to the item just below (before) tagOrId in the display list.
addtag_closest
Add the tag newtag to the item closest to the point (x, y).
addtag_enclosed
Add the tag newtag to every item completely enclosed within the rectangle (x1, y1, x2, y2), where x1 <= x2 and y1 <= y2.
addtag_overlapping
Add the tag newtag to every item that overlaps or is enclosed within the rectangle (x1, y1, x2, y2), where x1 <= x2 and y1 <= y2.
addtag_withtag
Add the tag newtag to every item given by tagOrId.

b

bbox
Return a 4-tuple (x1, y1, x2, y2) giving an approximate bounding box, in pixels, that encloses all the items given by tagOrId and any further tagOrIds.

c

canvasx
Given a window x-coordinate screenx, return the canvas x-coordinate displayed at that location.
canvasy
Given a window y-coordinate screeny, return the canvas y-coordinate displayed at that location.
coords
Query or modify the coordinates of an item.
create_arc
Create a new item of the corresponding type and return its integer id.
create_bitmap
Create a new item of the corresponding type and return its integer id.
create_image
Create a new item of the corresponding type and return its integer id.
create_line
Create a new item of the corresponding type and return its integer id.
create_oval
Create a new item of the corresponding type and return its integer id.
create_polygon
Create a new item of the corresponding type and return its integer id.
create_rectangle
Create a new item of the corresponding type and return its integer id.
create_text
Create a new item of the corresponding type and return its integer id.
create_window
Create a new item of the corresponding type and return its integer id.

d

dchars
Delete from each of the items given by tagOrId the characters (for text items) or coordinates (for line and polygon items) in the range from first to last inclusive; last defaults to first.
delete
Delete each of the items given by the tagOrIds arguments.
dtag
Remove the tag tagToDelete (which defaults to tagOrId) from each of the items given by tagOrId.

f

find
Return a tuple of the ids of all items selected by the search specification searchSpec (and any further args), in stacking order with the lowest item first.
find_above
Return a tuple containing the id of the item just above tagOrId in the display list.
find_all
Return a tuple of the ids of all items in the canvas, in stacking order.
find_below
Return a tuple containing the id of the item just below tagOrId in the display list.
find_closest
Return a tuple containing the id of the item closest to the point (x, y).
find_enclosed
Return a tuple of the ids of all items completely enclosed within the rectangle (x1, y1, x2, y2).
find_overlapping
Return a tuple of the ids of all items that overlap or are enclosed within the rectangle (x1, y1, x2, y2).
find_withtag
Return a tuple of the ids of all items given by tagOrId.
focus
With tagOrId, set the keyboard focus for the canvas to the first item given by tagOrId that supports the insertion cursor; the focus is left unchanged if no such item exists.

g

gettags
Return a tuple of the tags associated with the item given by tagOrId (the first matching item in display-list order if it matches several).

i

icursor
Set the insertion cursor of the items given by tagOrId to just before the character given by index.
index
Return as an integer the numerical index within tagOrId corresponding to index, which is a textual description of a position (for text items an index into the characters, for line and polygon items a…
insert
Insert string into each of the items given by tagOrId just before the character or coordinate whose index is beforeThis.
itemcget
Return the current value of the configuration option option for the item given by tagOrId (the lowest matching item if it matches several).
itemconfig
Query or modify the configuration options of the items given by tagOrId.
itemconfigure
Query or modify the configuration options of the items given by tagOrId.

l

lift
Move all items given by tagOrId to a new position in the display list just above the item given by aboveThis, or to the top of the display list if aboveThis is omitted.
lower
Move all items given by tagOrId to a new position in the display list just below the item given by belowThis, or to the bottom of the display list if belowThis is omitted.

m

move
Move each of the items given by tagOrId in the canvas coordinate space by adding xAmount to every x-coordinate and yAmount to every y-coordinate of the item.
moveto
Move the items given by tagOrId so that the first coordinate pair (the upper-left corner of the bounding box) of the lowest matching item is at position (x, y).

p

postscript
Generate a PostScript (Encapsulated PostScript, version 3.0) representation of part or all of the canvas.

s

scale
Rescale the coordinates of all items given by tagOrId in canvas coordinate space.
scan_dragto
Scroll the canvas by gain times the difference between x, y and the coordinates passed to the last scan_mark() call.
scan_mark
Record x, y and the current view, for use with later scan_dragto() calls.
select_adjust
Adjust the end of the selection in tagOrId nearest to index so that it is at index, and make the other end the anchor point for future select_to() calls.
select_clear
Clear the selection if it is in this canvas; otherwise do nothing.
select_from
Set the selection anchor point to just before the character given by index in the item given by tagOrId.
select_item
Return the id of the item that holds the selection, or None if the selection is not in this canvas.
select_to
Set the selection to the characters of tagOrId between the selection anchor point and index, inclusive of index.

t

tag_bind
Bind the callback func to the event sequence for all items given by tagOrId, so that func is invoked whenever that event occurs for one of the items.
tag_lower
Move all items given by tagOrId to a new position in the display list just below the item given by belowThis, or to the bottom of the display list if belowThis is omitted.
tag_raise
Move all items given by tagOrId to a new position in the display list just above the item given by aboveThis, or to the top of the display list if aboveThis is omitted.
tag_unbind
Remove for all items given by tagOrId the binding for the event sequence.
tkraise
Move all items given by tagOrId to a new position in the display list just above the item given by aboveThis, or to the top of the display list if aboveThis is omitted.
type
Return the type of the item given by tagOrId (the first matching item if it matches several), such as 'rectangle' or 'text', or None if tagOrId does not match any item.
0 Examples
No examples for tkinter/Canvas.
See Also
No see-alsos for tkinter/Canvas
0 Notes
No notes for Canvas