I am trying to print not just the Value of the radio button but also it's Name. so that I can do this "You selected 'Radio 2' with Value of '23' "
from tkinter import *
class Gui:
def __init__(self, master):
self.master = master
self.var = StringVar()
self.var.set("Cat")
radio1 = Radiobutton(self.master, variable=self.var, text="radio1", value="Cat")
radio1.bind('<Double-1>', lambda :self.show_radioname("radio1"))
radio1.pack()
radio2 = Radiobutton(self.master, variable=self.var, text="radio2", value="Dog")
radio2.bind('<Double-1>', lambda :self.show_radioname("radio2"))
radio2.pack()
radio3 = Radiobutton(self.master, variable=self.var, text="radio3", value="Horse")
radio3.bind('<Double-1>', lambda :self.show_radioname("radio3"))
radio3.pack()
submit_button = Button(self.master, text="print", command=self.show_var)
submit_button.pack()
def show_var(self):
print(self.var.get())
@staticmethod
def show_radioname(radio_name):
print(radio_name)
I can get the Value of The Radio But could not get their Text Name