Tkinter Box Radiobutton
The concept of a box radio button is also provided in tkinter, which can be set to 0 using the indicatoron parameter within the Radiobutton method.
Tkinter Box Radiobutton Example#1
Use box radio button.
from tkinter import *
def printSelection():
print(cities[var.get()],"Selected!!!")
root = Tk()
root.title("apidemos.com")
cities = { 0:"New York" ,1:"Houston",
2:"Washington",3:"Atlanta",
4:"New Jersey",5:"Tokyo",
}
var = IntVar()
var.set(0)
# var.set(0)
label = Label(root,text="Choose the city you like best",
fg="blue",bg="lightyellow",width=30)
label.pack()
for val,city in cities.items():
Radiobutton(
root,
text=city,
indicatoron = 0, # Replace Radiobutton with a box
width=30,
variable=var,value=val,
command=printSelection
).pack()
root.mainloop()
Output: