Difficulty using the function

  function, python, tkinter

I want to add a unit to the length and width of the table with each click on "btn1". This is the code:

from tkinter import*
win=Tk()
y=3
def func():
    global y
    y+=1
func()
for i in range(1,y):
    for j in range(1,y):
        frm=Frame(win,bd=2)
        frm.grid(row=i,column=j)
        btn=Button(frm,bg="red")
        btn.grid()
btn1=Button(win,command=func)
btn1.grid()
win.mainloop()

Source: Python Questions

LEAVE A COMMENT