I'm trying to return values of checkboxes that are selected in a tkinter GUI. The issue is that it seems to be running the Button(Command = "") before the button is clicked on, and therefore not returning that any boxes have been checked.
Here's a very stripped down version of the code with only 1 variable.
window = TK()
var1 = IntVar()
Checkbutton(window, text = "All", variable = var1).grid(row=1, column = 0, sticky = W)
runbtn = Button(window, text = "Run Report", command = print(var1.get()))
runbtn.grid(row=17, column=0, pady="5")
mainloop()
I've just set the command to print the variable state for this instance, so I can see if it's registering the checkbox input correctly. However, it prints out a "0" as soon as the program is run, without waiting for the button to be clicked. When I set the button to run another file, the button behaves correctly and only runs that file when clicked.
I'm unsure what I'm doing wrong here in order to be able to return the value of the checkboxes, after the user has been able to select them and click the runbtn.