Tkinter Canvas Drawing circles or ellipses
create_oval() It is used in the following way.
create_oval(x1, y1, x2, y2, options)
(x1,y1) and (x2,y2) are the coordinates of the upper-left and lower-right corners of a circle or ellipse, respectively. The following are the common uses of options.
(1) dash
: create dashed lines, same as create_line( ).
(2) dashoffset
: Generate dashed line like dash, but the number is the width of the blank at the beginning.
(3) fill
: set the fill color of the circle or ellipse.
(4) outline
: set the boundary color of the circle or ellipse.
(5) stipple
: draw the circle or ellipse of the bitmap boundary.
(6) width
: the width of the circle or ellipse line.
Example#1
Drawing of circles and ovals.
from tkinter import *
tk = Tk()
tk.title("apidemos.com")
canvas = Canvas(tk, width=640, height=480)
canvas.pack()
# Below is the circle
canvas.create_oval(10, 10, 110, 110)
canvas.create_oval(150, 10, 300, 160,fill="yellow")
# Below is the oval
canvas.create_oval(10, 200, 310, 350)
canvas.create_oval(350, 200, 550, 300,fill="aqua",outline="blue",width=5)
tk.mainloop()
Output: