I have got stuck with this particular bit of code. I have condensed down the problem to this section.
I am running a sort of menu in Python, where the first menu sends you to the second menu, and in the second menu, there is a checkbutton the user can toggle on/off. In the third menu, I want it to read if the checkbutton is on/off and convert it to a Boolean. Code:
import tkinter as tk
class MainMenu(object):
def __init__(self):
self.launch_MainMenu()
def launch_MainMenu(self):
self.master = tk.Tk()
tk.Button(self.master,text="MY BUTTON",command= lambda:self.launch_SideMenu()).grid()
tk.mainloop()
def launch_SideMenu(self):
self.master2 = tk.Tk()
self.var1 = tk.IntVar()
tk.Checkbutton(self.master2,variable=self.var1).grid()
tk.Button(self.master2,text="Test",command= lambda:self.launch_FinalMenu()).grid()
def launch_FinalMenu(self):
d = bool(int(self.var1.get()))
print(d,self.var1.get())
mainMenu = MainMenu()
Output: Whether the checkbox is on or off, it outputs "False 0".
Any help would be very much appreciated!
Tk()instance. You can't do that. Also it'd be better if you create your class variables(i.e.self.var1) in__init__method.tkinter.Toplevel()