Answers for "gui radio button python"

0

gui radio button python

import tkinter as tk
from tkinter import ttk
from tkinter.messagebox import askyesno, askquestion




def selected():
    print(confirmed.get())


root = tk.Tk()

confirmed = tk.StringVar() #used to get the 'value' property of a tkinter.Radiobutton

# Note that I added a command to each radio button and a different 'value'
# When you press a radio button, its corresponding 'command' is called.
# In this case, I am linking both radio buttons to the same command: 'selected'

rconfirmed = tk.Radiobutton(text='Radio Button 1', variable=confirmed, 
                          value="yes", command=selected)
rconfirmed.pack()
rconfirmed= tk.Radiobutton(text='Radio Button 2', variable=confirmed, 
                          value="no", command=selected)
rconfirmed.pack()

root.mainloop()
Posted by: Guest on August-17-2021

Python Answers by Framework

Browse Popular Code Answers by Language