Fix for bug 110629: Generate unique image names by introducing a counter

This commit is contained in:
Martin v. Löwis 2000-09-08 16:28:30 +00:00
parent 1a2eefdc4f
commit 0d8ce6111c
1 changed files with 3 additions and 1 deletions

View File

@ -2910,6 +2910,7 @@ class OptionMenu(Menubutton):
class Image: class Image:
"""Base class for images.""" """Base class for images."""
_last_id = 0
def __init__(self, imgtype, name=None, cnf={}, master=None, **kw): def __init__(self, imgtype, name=None, cnf={}, master=None, **kw):
self.name = None self.name = None
if not master: if not master:
@ -2918,7 +2919,8 @@ class Image:
raise RuntimeError, 'Too early to create image' raise RuntimeError, 'Too early to create image'
self.tk = master.tk self.tk = master.tk
if not name: if not name:
name = `id(self)` Image._last_id += 1
name = "pyimage" +`Image._last_id` # tk itself would use image<x>
# The following is needed for systems where id(x) # The following is needed for systems where id(x)
# can return a negative number, such as Linux/m68k: # can return a negative number, such as Linux/m68k:
if name[0] == '-': name = '_' + name[1:] if name[0] == '-': name = '_' + name[1:]