Creating RADIOBUTTONS in TKINTER

 

from tkinter import *
import tkinter.messagebox as tmsg

root = Tk()

def info():
    tmsg.showinfo("Your Response", f"Your response is {rad_var.get()}. Thanks!")
   
root.geometry("700x400")
root.title("Radiobutton Tutor")

Label(root, text="What is your Blood Group?", font="verdana 17 bold").pack()

rad_var = StringVar()
rad_var.set("+")

Radiobutton(root, text="B+", value="B+", variable=rad_var).pack(anchor=CENTER)
Radiobutton(root, text="A+", value="A+", variable=rad_var).pack(anchor=CENTER)
Radiobutton(root, text="AB+", value="AB+", variable=rad_var).pack(anchor=CENTER)
Radiobutton(root, text="AB-", value="AB-", variable=rad_var).pack(anchor=CENTER)
Radiobutton(root, text="O+", value="O+", variable=rad_var).pack(anchor=CENTER)

Button(root, text="Submit", command=info).pack()

root.mainloop()




Comments

Popular posts from this blog

Quotation marks to wrap an element in HTML

What is the difference between iostream and iostream.h in cpp?

The Basic Structure of a Full-Stack Web App