beetlebug▾
/

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:

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

See also