Jan-14-2022, 06:02 PM
I have been doing a work on Tic tac toes but I need help with the positioning I have set that when I press a button I draw a circle or an X but the problem is that it can draw where it wants but I need it to make it dead center of the square.
import tkinter canvas=tkinter.Canvas(width=700, height=700) canvas.pack() def board(): canvas.create_line(50,150,350,150) canvas.create_line(150,50,150,350) canvas.create_line(250,50,250,350) canvas.create_line(50,250,350,250) canvas.create_rectangle(50,50,350,350) def kruh(sur): x=sur.x y=sur.y canvas.create_oval(x-30,y-30,x+30,y+30, fill='blue') canvas.bind('<Button-1>', kruh) def stvorec(sur): x=sur.x y=sur.y canvas.create_rectangle(x-30,y-30,x+30,y+30,fill='red') canvas.bind('<Button-3>', stvorec)