Python - Tkinter RadioButton If Statement Python - Tkinter RadioButton If Statement tkinter tkinter

Python - Tkinter RadioButton If Statement


You can use lambda to pass your function with argument.

for txt, val in languages:    Radiobutton(root,                 text=txt,                padx = 20,                 variable=v,                 command=lambda: ShowChoice(root),                value=val).pack(anchor=W)

In the ShowChoice function, just use if/else to do 'stuff' depending on what is selected.For example.

def ShowChoice(root):    world = v.get()    if world == 0:       root.destroy()