1import tkinter as tk
2from tkinter import ttk
3from tkinter.messagebox import askyesno, askquestion
4
5
6
7
8def selected():
9 print(confirmed.get())
10
11
12root = tk.Tk()
13
14confirmed = tk.StringVar() #used to get the 'value' property of a tkinter.Radiobutton
15
16# Note that I added a command to each radio button and a different 'value'
17# When you press a radio button, its corresponding 'command' is called.
18# In this case, I am linking both radio buttons to the same command: 'selected'
19
20rconfirmed = tk.Radiobutton(text='Radio Button 1', variable=confirmed,
21 value="yes", command=selected)
22rconfirmed.pack()
23rconfirmed= tk.Radiobutton(text='Radio Button 2', variable=confirmed,
24 value="no", command=selected)
25rconfirmed.pack()
26
27root.mainloop()
28