Calling A Tk Instance From Another Tk Instance Causes Issue Setting Textvariables
Solution 1:
Having two Tk
instances confuses it. If you want things displayed in a separate top-level window, call Toplevel()
instead and things will work.
def load_dropdown():
parent =Toplevel() # <- change to this
myvalue = StringVar()
...
Solution 2:
You cannot use more than once instance of Tk
in a tkinter application. You are observing one of the negative side-effects of trying to do so.
If you need a second window, create an instance of Toplevel rather than a second instance of Tk
.
Solution 3:
In tkinter you only ever create one mainloop which is done by root = Tk()
This is your default window. Your example will work if you get rid of the second creation of parent.
To create more windows use new_window = TopLevel()
There is a lot of good documentation on tkinter, make use of it and it will take you far :)
http://effbot.org/tkinterbook/toplevel.htm
http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/toplevel.html
Post a Comment for "Calling A Tk Instance From Another Tk Instance Causes Issue Setting Textvariables"