Advertisement
here2share

# tk_checkboxes.py

Aug 5th, 2024
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.45 KB | None | 0 0
  1. # tk_checkboxes.py
  2.  
  3. import tkinter as tk
  4.  
  5. root = tk.Tk()
  6. root.title("Checkbox Example")
  7.  
  8. sss = '1 2* 3* 4 5'.split()
  9.  
  10. def create_checkboxes(items):
  11.     for item in items:
  12.         var = tk.BooleanVar()
  13.         if '*' in item:
  14.             var.set(1)
  15.         item = item[0]
  16.         cb = tk.Checkbutton(root, text=item, variable=var)
  17.         cb.pack(anchor='w')
  18.         variables.append(var)
  19.  
  20. variables = []
  21. create_checkboxes(sss)
  22.  
  23. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement