tkinter drawing circle code example
Example 1: tkinter draw squaer
from Tkinter import *
master = Tk()
w = Canvas(master, width=250, height=200)
w.create_rectangle(0, 0, 100, 100, fill="blue", outline = 'blue')
w.create_rectangle(50, 50, 100, 100, fill="red", outline = 'blue')
w.pack()
master.mainloop()
Example 2: tkinter draw circle
from tkinter import *
root = Tk()
myCanvas = Canvas(root)
myCanvas.pack()
def create_circle(x, y, r, canvasName):
x0 = x - r
y0 = y - r
x1 = x + r
y1 = y + r
return canvasName.create_oval(x0, y0, x1, y1)
create_circle(100, 100, 20, myCanvas)
create_circle(50, 25, 10, myCanvas)
root.mainloop()