]> granicus.if.org Git - python/commitdiff
Issue #802310: Generate always unique tkinter font names if not directly passed
authorAndrew Svetlov <andrew.svetlov@gmail.com>
Tue, 3 Apr 2012 06:48:07 +0000 (09:48 +0300)
committerAndrew Svetlov <andrew.svetlov@gmail.com>
Tue, 3 Apr 2012 06:48:07 +0000 (09:48 +0300)
Lib/tkinter/font.py
Misc/NEWS

index 0103195da3dd543d6835e436febd177d944cdd86..27e0cc849a85c7e8abdad7a4e30ae3320b63ec99 100644 (file)
@@ -8,6 +8,7 @@
 
 __version__ = "0.9"
 
+import itertools
 import tkinter
 
 
@@ -46,6 +47,8 @@ class Font:
 
     """
 
+    counter = itertools.count(1)
+
     def _set(self, kw):
         options = []
         for k, v in kw.items():
@@ -75,7 +78,7 @@ class Font:
         else:
             font = self._set(options)
         if not name:
-            name = "font" + str(id(self))
+            name = "font" + str(next(self.counter))
         self.name = name
 
         if exists:
index 2a05802de937a42e3f089028293f350c82fc13ba..5d8b97522ba4073f3d3421875911511b67671768 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -19,6 +19,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #802310: Generate always unique tkinter font names if not directly passed.
+
 - Issue #14151: Raise a ValueError, not a NameError, when trying to create
   a multiprocessing Client or Listener with an AF_PIPE type address under
   non-Windows platforms.  Patch by Popa Claudiu.