Python Checkbutton reads value only once
I've looked in StackOverflow for any similar problems, but the only one that looked similar was this here. It suggested that in this case the variable should be set global but I don't think that's a good solution. So I'm asking you guys for a better one.
I want to use Checkbutton() in Python and my code looks (simplified) like this...
#!/usr/bin/env
from Tkinter import *
Fenster = Tk()
Fenster.title ("Sensors")
Number = IntVar()
Button = Checkbutton(Fenster, text = "Check me", variable = Number, onvalue = 1, offvalue = 0)
print Number.get()
Button.pack()
mainloop()
When i run this code, the window opens and i see the Checkbox. So far so good. But when I want to check or uncheck it, the value of "Number" somehow doesn't change. It only displays "1", probably from the first frame, and never changes.
Could you give me some advice how to improve this?