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

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 developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.