I tried to create a matrix of checkbuttons and then access all the checkbuttons, but the answer is always 0.
x = dict()
var = dict()
for i in range(1, ex +1):
for j in range(1, ey +1):
Label(root, text=i, bg="#B8B8B8").place(x=i*25+ 3, y=10)
Label(root, text=j, bg="#B8B8B8").place(x=10, y=j*25+ 3)
var[i, j] = IntVar()
x[i,j] = var[i, j].get()
Checkbutton(root, bg="#B8B8B8", variable=var[i,j]).place(x=i*25, y=j*25)
Button(root, text="click", command=lambda: print(x[1, 1]) ).pack()