Radiobutttons, LabelFrame, Frame,
Radiobuttons are a blast and can be used several ways. This lettle demo shows them managing a selection horizontally.
#TEST AREA for Radiobuttons - horizontal #standard set up header code 2 from tkinter import * root = Tk() root.attributes('-fullscreen', True) root.configure(background='SteelBlue4') scrW = root.winfo_screenwidth() scrH = root.winfo_screenheight() workwindow = str(1024) + "x" + str(768)+ "+" +str(int((scrW-1024)/2)) + "+" +str(int((scrH-768)/2)) top1 = Toplevel(root, bg="light blue") top1.geometry(workwindow) top1.title("Top 1 - Workwindow") top1.attributes("-topmost", 1) # make sure top1 is on top to start root.update() # but don't leave it locked in place top1.attributes("-topmost", 0) # in case you use lower or lift #exit button - note: uses grid b3=Button(root, text="Egress", command=root.destroy) b3.grid(row=0,column=0,ipadx=10, ipady=10, pady=5, padx=5, sticky = W+N) #____________________________ def sel(): selection = "You selected the option " + str(var.get()) l2.config(text = selection) var = IntVar() # all Radiobutton widgets will be set to the same control variable showfont="Georgia 16 bold" # define a consistent font to use # first a labelframe to create some space to the left and above lf1=LabelFrame(top1, width=250, height=175, relief=GROOVE, bg="light blue") lf1.grid(column=0,row=0) # set relief to groove so position can be seen - FLAT=invisible # now a frame to put our buttons in f2=Frame(top1, width=50, relief= SUNKEN, bd=10) f2.grid(column=1,row=2, sticky=W) # for our frame we make and then pack 3 nice buttons with values R1 = Radiobutton(f2, anchor=W, text="1", variable=var, value=1, command=sel, font=showfont, width=3) R1.pack(anchor=W, side=LEFT, ipadx=10) R2 = Radiobutton(f2, anchor=W, text="2", variable=var, value=2, command=sel, font=showfont, width=3) R2.pack(anchor=W, side=LEFT, ipadx=10) R3 = Radiobutton(f2, anchor=W, text="3", variable=var, value=3, command=sel, font=showfont, width=3) R3.pack(anchor=W, side=LEFT) # on top of it all a simple instruction label l1=Label(top1, width=20, anchor='center', font=showfont, relief="raised", bd=7, text="Click a value") l1.grid(column=1, row=1, pady=20, sticky='w') # an underneath, a lable to show our action l2 = Label(top1, width=21, anchor='w', font=showfont, relief="raised", bd=7, text="No selections have been made.") l2.grid(column=1, row=3, pady=20, ipady=10, ipadx=20, sticky='w') #____________________________ root.mainloop()