FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.15] gh-123193: Document tkinter Variable lifetime (GH-152625) by miss-islington · Pull Request #153098 · python/cpython · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .rst  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
11 changes: 11 additions & 0 deletions Doc/library/tkinter.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,9 @@ method on it, and to change its value you call the :meth:`!set` method.
If you follow this protocol, the widget will always track the value of the
variable, with no further intervention on your part.

Keep a reference to the variable for as long as a widget uses it, for example
by storing it as an attribute (see :class:`Variable`).

For example::

import tkinter as tk
Expand Down Expand Up @@ -5733,6 +5736,14 @@ Variable classes
:class:`StringVar`, :class:`IntVar`, :class:`DoubleVar` or
:class:`BooleanVar` -- rather than :class:`!Variable` directly.

.. note::

When a :class:`!Variable` is garbage collected, its Tcl variable is unset.
Keep a reference to it for as long as a widget is linked to it, for example
by storing it as an attribute rather than in a local variable.
Otherwise Tk recreates the Tcl variable to keep the widget working, but it
is never unset again, leaking one Tcl variable per dropped wrapper.

.. versionchanged:: 3.10
Two variables now compare equal (``==``) only when they have the same
name, are of the same class, and belong to the same Tcl interpreter.
Expand Down
Loading

Back | FazBrowse Home | New Git URL