canvas create
Makes an item of TYPE and gives its ID.
PATHNAME create TYPE X Y ?X Y ...? ?OPTION VALUE ...?
Description
Makes a new item above the other items. The coordinates can be words or one list. Each type has its count of coordinates and its options:
line: two or more points.-fill,-width,-dash,-arrow(none,first,last, orboth),-arrowshape,-capstyle,-joinstyle,-smooth, and-splinesteps.rectangleandoval: two corners.-fill,-outline,-width, and-dash.polygon: three or more points.-fill,-outline,-width,-joinstyle,-smooth, and-splinesteps.arc: two corners of the oval of the arc.-startand-extentin degrees,-style(pieslice,chord, orarc), and the options of an oval.text: one point.-text,-font,-fill,-anchor,-justify,-widthfor the wrap length,-underline, and-angle, the degrees that the text turns anticlockwise around its anchor; the box,find,closest, andindex @x,yfollow the turn.image: one point.-imageand-anchor.bitmap: one point.-bitmap,-foreground,-background, and-anchor.window: one point.-windowfor a child widget of the canvas,-width,-height, and-anchor.
Each type has -tags and -state (normal, disabled, or hidden). The types with colors also have -active and -disabled forms of their options, such as -activefill, for the active and the disabled states. itemconfigure lists the full options of an item.
Returns
The ID of the new item.
Examples
% canvas .cr
> .cr create line 0 0 100 100 -arrow last -width 2
1
% canvas .cr2
> .cr2 create text 20 20 -text Hello -anchor nw
> .cr2 type 1
text
Errors
% canvas .cr3; .cr3 create bogus 1 2
unknown or ambiguous item type "bogus"
-errorcode NONE
% canvas .cr4; .cr4 create rectangle 1 2
wrong # coordinates: expected 0 or 4, got 2
-errorcode NONE
% canvas .cr5; .cr5 create line 0 0 10 10 -arrow sideways
bad arrow spec "sideways": must be none, first, last, or both
-errorcode NONE
% canvas .cr6; .cr6 create line 1 2 3 4 -foo 1
unknown option "-foo"
-errorcode NONE
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztk 1.0.0-beta.1