I want to initiate a class variable in order to pass it to another class. This variable has to be a StringVar variable as I want to use it for an Entry function of Tkinter. What I have done so far is this:
class ClassA:
var1 = StringVar()
def __init__(self,master):
entry1 = Entry(master, textvariable = var1)
root = Tk()
my_gui = ClassA(root)
root.mainloop()
However, it gives the message:
StringVar instance has no attribute '_tk'.
This can be solved by adding Tk() before the declaration of StringVar but this produces a new window when I start my app. Is there a way to declare it without having to add the Tk() line? I can't figure out why this happens as I initiate Tk() outside the class.