Question: I am trying to make my check buttons in python tkinter to be deselected if the no toppings button is checked and otherwise all other

I am trying to make my check buttons in python tkinter to be deselected if the no toppings button is checked and otherwise all other options could be checked. How to I edit my code to achieve this?
# creating label for taco toppings
topping_label = Label(self.order_frame, text="Taco Toppings:", font=label_font, fg=color_font)
topping_label.grid(row=8, column=0, sticky="E")
# creating list for topping options
topping_options =[
"None",
"Pico",
"Cheddar Cheese",
"Sour Cream",
"Pickled Red Onions",
"Jack Cheese"
]
# declaring variable as string for no topping option
none_selected = StringVar()
none_selected.set(none_selected.get())
# declaring variable as string for pico option
pico_selected = StringVar()
pico_selected.set(pico_selected.get())
# declaring variable as string for cheddar cheese option
cheddar_cheese = StringVar()
cheddar_cheese.set(cheddar_cheese.get())
# declaring variable as string for sour cream option
sour_cream = StringVar()
sour_cream.set(sour_cream.get())
# declaring variable as string for pickled onions option
pickled_onions = StringVar()
pickled_onions.set(pickled_onions.get())
# declaring variable as string for jack cheese option
jack_cheese = StringVar()
jack_cheese.set(jack_cheese.get())
# creating check buttons for each taco topping
# check box for no toppings
self.topping_options = Checkbutton(self.order_frame, text=topping_options[0], variable=none_selected,
onvalue="No Toppings", offvalue="", fg=input_color, font=label_font)
self.topping_options.select()
self.topping_options.grid(row=8, column=1, sticky="W")
# check box for pico topping
self.topping_options = Checkbutton(self.order_frame, text=topping_options[1], variable=pico_selected,
onvalue="Pico ", offvalue="", fg=input_color, font=label_font)
self.topping_options.deselect()
self.topping_options.grid(row=8, column=2, sticky="W")
# check box for cheddar cheese
self.topping_options = Checkbutton(self.order_frame, text=topping_options[2], variable=cheddar_cheese,
onvalue="Cheddar Cheese ", offvalue="", fg=input_color, font=label_font)
self.topping_options.deselect()
self.topping_options.grid(row=9, column=1, sticky="W")
# check box for sour cream
self.topping_options = Checkbutton(self.order_frame, text=topping_options[3], variable=sour_cream,
onvalue="Sour Cream ", offvalue="", fg=input_color, font=label_font)
self.topping_options.deselect()
self.topping_options.grid(row=9, column=2, sticky="W")
# check box for pickled red onions
self.topping_options = Checkbutton(self.order_frame, text=topping_options[4], variable=pickled_onions,
onvalue="Pickled Red Onions ", offvalue="", fg=input_color, font=label_font)
self.topping_options.deselect()
self.topping_options.grid(row=10, column=1, sticky="W")
# check boc for jack cheese
self.topping_options = Checkbutton(self.order_frame, text=topping_options[5], variable=jack_cheese,
onvalue="Jack Cheese ", offvalue="", fg=input_color, font=label_font)
self.topping_options.deselect()
self.topping_options.grid(row=10, column=2, sticky="W")

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!