Suppose i have one dictionary menu={'pizza':1,'Burger':1,'sandwitch':0}
when i run tkinter gui these all key will be displayed on GUI. If value is 1 then respected key must be ticked rest will be unticked

Recommended Answers

Use radiobuttons instead.

Jump to Post

All 2 Replies

Use radiobuttons instead.

commented: Checks out. +11

python3:

import tkinter as tk
master = tk.Tk()
menu={'pizza':1,'Burger':1,'sandwitch':0}
menuvars={}
for row, (key, value) in enumerate(menu.items()):
    menuvars[key]=tk.IntVar()
    menuvars[key].set(value)
    tk.Checkbutton(master, text=key, variable=menuvars[key]).grid(row=row, sticky=tk.W)
tk.mainloop()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.