Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #like to know how to do more of this kind of work
- #how to work with classes?
- #so much to know!
- #there's no title for this button box
- #all content is written to terminal
- #I would want to write it to a file...
- import tkinter as tk
- class GUI(tk.Tk):
- def __init__(self):
- tk.Tk.__init__(self)
- #the output of the dictionary items are not kept the same!
- self.buttonDic = {
- 'has purchased seat blocks':0,
- 'prefer to work directly with hotel':0,
- '':0,
- 'Black Beans':0
- }
- for key in self.buttonDic:
- self.buttonDic[key] = tk.IntVar()
- aCheckButton = tk.Checkbutton(self, text=key,
- variable=self.buttonDic[key])
- aCheckButton.grid(sticky='w')
- submitButton = tk.Button(self, text="Submit",
- command=self.query_checkbuttons)
- submitButton.grid()
- def query_checkbuttons(self):
- for key, value in self.buttonDic.items():
- state = value.get()
- if state != 0:
- print(key)
- self.buttonDic[key].set(0)
- gui = GUI()
- gui.mainloop()
Add Comment
Please, Sign In to add comment