Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

Tkinter 'textvariable' does not work in a secondary window?

Because when I use textvariable from a secondary window that was called from a command in another window, the value set through .set () is not reflected in the secondary window Label.

Example:

Code
import tkinter as tk

def test():
   ven=tk.Tk()
   v1=tk.StringVar()
   v1.set('TEST')
   print(v1.get())
   tk.Label(ven, textvariable=v1).pack()
   ven.mainloop()

win=tk.Tk()
tk.Button(text='BOTON',command=test).pack()
win.mainloop()

In this case, the 'TEST' message set through v1.set () is not updated in the text variable of the Label that was created in the test() function

Why does this happen?


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by MiguelSanchezApr 12, 2022 02:13 PM 1 159 Apr 12, 2022 02:13 PM
Last Post: lightduty
[Python] by RevNucleusJul 24, 2021 10:40 PM 2 154 Jul 24, 2021 10:40 PM
Last Post: RevNucleus
[Python] by DocJun 2, 2021 07:06 AM 6 269 Jun 2, 2021 07:06 AM
Last Post: synchronizing