The canvas widget is used to display all kind of graphics output.
Graphic components are defined as objects like line, circle and
photoimage which are displayed on the canvas. These objects can be
modified through methods to change their appearance. The display and
redrawing is handled by the canvas widget automatically, so that the
user does not need to care for that. For convenience, ltk adds a
scrolled-canvas widget which contains a canvas widget and adds
automatically scrollbars to it. You gain access to the contained
canvas with the
A canvas widget is created by the
make-canvas function. It has
the optional arguments
height for the width
and height used to display the canvas widget. The drawing region
itself can be bigger, its size is set by the
method, which has the canvas and the dimension as the coordinates x0
y0 and x1 y1 as parameters.
Objects to be displayed in a canvas are created via the create-xxx methods, with xxx the type of object to be created. They take the canvas as first argument and return an index (integer) which is used as handle for the modifying functions. A list of currently supported objects and the create method parameters:
Creates an arc item. The arc angles are specified in starting angle and extend of the arc. So a quater circle would have an extent of 90. Style determines how the arc is rendered. Available styles are:
Creates an bitmap on the canvas, if bitmap is given, its displayed in this item. Special configuration options are:
Creates an image on the canvas, if image is given, its displayed in this image. Special configuration options are:
Coords is a list of the coordinates of the line in the form (x0 y0 x1 y1 x2 y2 ...). Lines with any number of segments can be created this way. Special configuration options for line items (see itemconfigure) are:
Like create-line, but the coordinates are directly given in the form x0 y0 x1 y1 x2 y2 .
Creates an oval fitting within the rectangular of the given coordinates.
Similiar to create-line, creates a closed polygon.
Special configuration options for polygon items (see itemconfigure) are:
Creates an rectangle with the given coordinates.
Creates a text displaying object at the position x,y. Text is the string to be displayed. Special configuration options are:
Embeds a widget into the canvas at the position (x y). The widget has to be created before with canvas or one of the masters of canvas as its master.