Nov-24-2021, 09:54 AM
Hi, yes now I able to run this code having radio buttons which are arranged in rows and cols and are linked together. The buttons A and B are linked and have their value in same variable. Same is true for buttons C and D.
Now I need to print their their values when the radio button is selected but I it is not printing the values in the code below.
Now I need to print their their values when the radio button is selected but I it is not printing the values in the code below.
import tkinter as tk root = tk.Tk() var_ab = tk.IntVar() var_cd = tk.IntVar() tk.Label(root, text="""Radio Buttons""", justify = tk.LEFT).grid (row = 1, column = 1) tk.Radiobutton(root, text="A", padx = 20, variable=var_ab, value=1).grid (row = 2, column = 1) tk.Radiobutton(root, text="B", padx = 20, variable=var_ab, value=2).grid (row = 2, column = 2) tk.Radiobutton(root, text="C", padx = 20, variable=var_cd, value=3).grid (row = 3, column = 1) tk.Radiobutton(root, text="D", padx = 20, variable=var_cd, value=4).grid (row = 3, column = 2) print("The Variable AB = " , var_ab) print("The Variable CD = " , var_cd) root.mainloop()