1
나는 0, 1 또는 2를 선택할 수있는 라디오 버튼이 있습니다. 다음 스크립트는 터미널에서 0, 1 또는 2를 출력하지만, 나는 그것에 따라 'stuff'를하고 싶습니다. 내가 선택한 것. 내가 0을 선택하면Python-Tkinter RadioButton If 문
예를 들어, 나는 그것이 root.destroy() 나는 1을 선택하면 , 나는 그것이 내가 선언 할 필요가 거라고 생각
등 다른 일을하고 싶어하고 싶어 전역 변수이지만 작동하지 않는 것 같습니다.다음은 스크립트입니다.
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()