I am new with Tkinter and Python. I am working with some checkboxes and button functions. I want the output to be output: 0, output: 1,...
(0 is when the checkbox is not ticked and 1 is when the checkbox is ticked). The output is printed whenever the Submit button is pressed. Since at this moment, it is only printed once at the beginning
I just wonder if there is any a way to do that
Thank you and have a nice day :)
import tkinter as tk
from tkinter import *
root = tk.Tk()
class Blah:
def __init__(self):
self.varAll = IntVar()
def Check(self):
but1 = Checkbutton(root, text='Selected', variable = self.varAll)
but1.pack(side=LEFT, pady=4)
b2 = tk.Button(root, text='Submit', command= self.State)
b2.pack(side=tk.LEFT, padx=5, pady=15)
b2.wait_variable(self.varAll)
def State(self):
print('State: ', self.varAll.get())
self.state = self.varAll.get()
return self.state
def Main():
listt = Blah()
listt.Check()
#root.wait_variable(listt.varAll)
print("output ", listt.varAll.get())
if __name__ == '__main__':
Main()