What I want to do is create a circle using create_oval()
with the radius r
entered in Entry()
widget. I don't understand what the problem is. Here's my code:
from tkinter import *
root = Tk()
#Drawing the circle
def circle(canvas,x,y,r):
id = canvas.create_oval(x-r,y-r,x+r,y+r)
return id
#Label
radiusLabel = Label(root, text="Enter the radius: ")
radiusLabel.grid(row=0,column=0)
#Entering the radius
radiusEntry = Entry(root)
radiusEntry.grid(row=1, column=0)
r = int(radiusEntry.get())
#Canvas
canvas = Canvas(width=400,height=400, bg="#cedbd2")
canvas.grid(row=2,column=0)
#Calling the function for drawing the circle button
radiusButton = Button(root, text="Create",command=circle(canvas,100,100,r))
radiusButton.grid(row=2,column=1)
root.mainLoop()