from tkinter import *
def mouse1(event):
global canvas
it_1 = event.x//100 * 100
it_2 = event.y//100 * 100
canvas.create_rectangle(it_1,it_2, it_1+90,it_2+90, outline="#f11", fill="#fff", width=2)
root = Tk()
root.geometry("500x500")
root.bind('<Button-1>', mouse1)
canvas = Canvas(root, width = 500, height = 500)
canvas.place(x = 0 ,y = 0)
for it_1 in range(0,500,100):
for it_2 in range(0,500,100):
canvas.create_rectangle(it_1,it_2, it_1+90,it_2+90, outline="#f11", fill="#1f1", width=2)
root.mainloop()
|