I'm just doing my first steps in tkinter and I'm stuck trying to figure out why this code is not working:
from tkinter import *
from tkinter import ttk
root = Tk()
spam = StringVar()
checkbutton = ttk.Checkbutton(
root, text="SPAM?", variable=spam, onvalue="Yes, SPAM!", offvalue="Boo, SPAM!")
checkbutton.pack()
print(spam.get())
root.mainloop()
The variable spam is empty, no matter if my checkbutton is checked or unchecked. Looking at the examples and documentation was a dead end too. Why is my variable still empty?