]> granicus.if.org Git - python/commitdiff
Turn leading minus sign into underscore for image widget name -- the
authorGuido van Rossum <guido@python.org>
Wed, 20 Nov 1996 22:17:38 +0000 (22:17 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 20 Nov 1996 22:17:38 +0000 (22:17 +0000)
hyphen confused Tk into thinking the name was an option.

Lib/lib-tk/Tkinter.py
Lib/tkinter/Tkinter.py

index 5dd0c99b186f0cc9101731f9e75573ccd1c5fb33..c482f46122654871448b5e8137086eeb8a0202f5 100644 (file)
@@ -54,7 +54,6 @@ def _cnfmerge(cnfs):
        if type(cnfs) is DictionaryType:
                return cnfs
        elif type(cnfs) in (NoneType, StringType):
-               
                return cnfs
        else:
                cnf = {}
@@ -1531,7 +1530,6 @@ class _setit:
        def __init__(self, var, value):
                self.__value = value
                self.__var = var
-
        def __call__(self, *args):
                self.__var.set(self.__value)
 
@@ -1564,7 +1562,11 @@ class Image:
                master = _default_root
                if not master: raise RuntimeError, 'Too early to create image'
                self.tk = master.tk
-               if not name: name = `id(self)`
+               if not name:
+                       name = `id(self)`
+                       # The following is needed for systems where id(x)
+                       # can return a negative number, such as Linux/m68k:
+                       if name[0] == '-': name = '_' + name[1:]
                if kw and cnf: cnf = _cnfmerge((cnf, kw))
                elif kw: cnf = kw
                options = ()
index 5dd0c99b186f0cc9101731f9e75573ccd1c5fb33..c482f46122654871448b5e8137086eeb8a0202f5 100755 (executable)
@@ -54,7 +54,6 @@ def _cnfmerge(cnfs):
        if type(cnfs) is DictionaryType:
                return cnfs
        elif type(cnfs) in (NoneType, StringType):
-               
                return cnfs
        else:
                cnf = {}
@@ -1531,7 +1530,6 @@ class _setit:
        def __init__(self, var, value):
                self.__value = value
                self.__var = var
-
        def __call__(self, *args):
                self.__var.set(self.__value)
 
@@ -1564,7 +1562,11 @@ class Image:
                master = _default_root
                if not master: raise RuntimeError, 'Too early to create image'
                self.tk = master.tk
-               if not name: name = `id(self)`
+               if not name:
+                       name = `id(self)`
+                       # The following is needed for systems where id(x)
+                       # can return a negative number, such as Linux/m68k:
+                       if name[0] == '-': name = '_' + name[1:]
                if kw and cnf: cnf = _cnfmerge((cnf, kw))
                elif kw: cnf = kw
                options = ()