diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2014-08-17 12:31:59 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2014-08-17 12:31:59 (GMT) |
commit | 87bbf257ef6e8d1e5876776094db609702ee468a (patch) | |
tree | e14628efdf2032a43d18a68a4aa63c31abc272bd /Lib/tkinter/font.py | |
parent | 97f17ff8405e1b6741ff1b1412befd0190896ae7 (diff) | |
download | cpython-87bbf257ef6e8d1e5876776094db609702ee468a.zip cpython-87bbf257ef6e8d1e5876776094db609702ee468a.tar.gz cpython-87bbf257ef6e8d1e5876776094db609702ee468a.tar.bz2 |
Issue #22068: Avoided reference loops with Variables and Fonts in Tkinter.
Diffstat (limited to 'Lib/tkinter/font.py')
-rw-r--r-- | Lib/tkinter/font.py | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/Lib/tkinter/font.py b/Lib/tkinter/font.py index 2096093..b966732 100644 --- a/Lib/tkinter/font.py +++ b/Lib/tkinter/font.py @@ -69,9 +69,10 @@ class Font: **options): if not root: root = tkinter._default_root + tk = getattr(root, 'tk', root) if font: # get actual settings corresponding to the given font - font = root.tk.splitlist(root.tk.call("font", "actual", font)) + font = tk.splitlist(tk.call("font", "actual", font)) else: font = self._set(options) if not name: @@ -81,21 +82,19 @@ class Font: if exists: self.delete_font = False # confirm font exists - if self.name not in root.tk.splitlist( - root.tk.call("font", "names")): + if self.name not in tk.splitlist(tk.call("font", "names")): raise tkinter._tkinter.TclError( "named font %s does not already exist" % (self.name,)) # if font config info supplied, apply it if font: - root.tk.call("font", "configure", self.name, *font) + tk.call("font", "configure", self.name, *font) else: # create new font (raises TclError if the font exists) - root.tk.call("font", "create", self.name, *font) + tk.call("font", "create", self.name, *font) self.delete_font = True - # backlinks! - self._root = root - self._split = root.tk.splitlist - self._call = root.tk.call + self._tk = tk + self._split = tk.splitlist + self._call = tk.call def __str__(self): return self.name @@ -120,7 +119,7 @@ class Font: def copy(self): "Return a distinct copy of the current font" - return Font(self._root, **self.actual()) + return Font(self._tk, **self.actual()) def actual(self, option=None, displayof=None): "Return actual font attributes" |