Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 18732

Python, How to stop tkinter variables from being garbage-collected?

$
0
0

I have a function that creates a tkinter window with many checkbutton widgets on it. Later, a button on another window saves the states of these checkbuttons. The function that does this is passed the reference to the window the checkbuttons are on, through which (by .winfo_children()) it gets the references to each checkbutton widget.

Even though all the checkbuttons on the window are created, set, and get'd identically, different ones throw an error each time the code is run: _tkinter.TclError: can't read "PY_VAR0": no such variable.

This leads me to believe that some of my BooleanVar() tkinter variables are being garbage-collected while I still need them. How do I stop my tkinter variables from being garbage-collected?


Similar to this question, but I would prefer a solution that stops the garbage-collection in the first place, as changing the structure of my functions would be difficult.


Viewing all articles
Browse latest Browse all 18732

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>