Skip to content Skip to sidebar Skip to footer

Tkinter Variable Trace Method

I am trying to activate callback function as the user type in to the tkinter entry box. According to effbot.org, You can use the trace method to attach “observer” callbacks to

Solution 1:

stringvar1 is garbage collected (deleted) when Entrybox_002 function return.

Workaround:

stringvar1 = window2.stringvar1 = tk.StringVar(value='asdf')

I recommend you code Entrybox_002 as class, and stringvar1 as instance attribute to keep reference.

Post a Comment for "Tkinter Variable Trace Method"