Следующий код отслеживает то, что они нажали:
choice=None
def choice1():
global choice
choice='Choice 1'
def choice2():
global choice
choice='Choice 2'
def start():
global choice
if choice=='Choice 1':
foo1()
elif choice=='Choice 2':
foo2()
else:
#do something else since they didn't press either
Передайте choice1
в качестве команды для Choice_1_Button
, choice2
в качестве команды для Choice_2_Button
и start
для Start_Button
.
Если вы хотите использовать радиокнопки, вам будет проще:
def start(choice):
if choice=='Choice 1':
foo1()
elif choice=='Choice 2':
foo2()
else:
#do something else since they didn't press either
var=StringVar(root)
var.set(None)
Radiobutton(root, text='Choice 1', value='Choice 1', variable=var).pack()
Radiobutton(root, text='Choice 2', value='Choice 2', variable=var).pack()
Button(self.frame, text='Start', command=lambda: start(var.get())).pack()