Name
create_polygon
Synopsis
c
.create_polygon(*coordinates
, **poly_options
)
Creates a polygon
item with vertices at the given
coordinates
and returns the
item’s handle.
coordinates
must be an even number of
positional parameters, alternately x
and
y
values for each vertex of the polygon, and there
must be at least six positional parameters (three vertices).
poly_options
may include:
-
fill
The polygon’s interior color (default is black)
-
outline
The polygon’s perimeter color (default is black)
-
smooth
If true, the polygon is drawn as a smooth curve (a B-spline); otherwise (default), the line is drawn as a normal polygon (a sequence of sides)
-
tags
A string (to assign a single tag to this item) or a tuple of strings (to assign multiple tags to this item)
-
width
Width of the perimeter line in pixels (default
1
)
For example:
x
=c.create_polygon(0,150, 50,100, 0,50, 50,0 fill='',
outline='red')
draws two empty red triangles on c
as a
single polygon, and binds the polygon’s handle to
variable x
. You can then fill the
triangles with blue using:
c
.itemconfig(x,fill='blue')
Get Python in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.