I've got a radio button which lets me select 0, 1 or 2. The following script prints 0, 1 or 2 in the terminal, but I want it to do 'stuff' depending on what I select.
For example, If I select 0, I want it to do a root.destroy() If I select 1, I want it to do something else etc.
I thought I'd need to declare a global variable, but it doesn't seem to work.
Here is the script.
root = Tk()
v = IntVar()
v.set(0) # set to 0 pics as default. Just looks prettier...
languages = [
("0 Pics",0),
("1 Pic",1),
("2 Pics",2),
]
def ShowChoice():
world = v.get()
global world
print world
Label(root, text="""How many pictures do you have left to scan?""", padx = 15).pack()
for txt, val in languages:
Radiobutton(root,
text=txt,
padx = 20,
variable=v,
command=ShowChoice,
value=val).pack(anchor=W)
mainloop()
Radiobutton(root,
text=txt,
indicatoron = 0,
width = 20,
padx = 20,
variable=v,
command=ShowChoice,
value=val).pack(anchor=W)
print 'The V get variable is: ' + world()