]> granicus.if.org Git - python/commitdiff
For StringVar results to strings. Document that boolean things are of
authorMartin v. Löwis <martin@v.loewis.de>
Wed, 16 Apr 2003 19:42:51 +0000 (19:42 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Wed, 16 Apr 2003 19:42:51 +0000 (19:42 +0000)
type bool. Requested in #721171.

Lib/lib-tk/Tkinter.py
Misc/NEWS

index 8fa8e6e4bb7d05fe6daf82bd76a81ebdd9a31a84..bd36d10f586e033b9aaf369ad94ce6b84a167bb7 100644 (file)
@@ -223,7 +223,10 @@ class StringVar(Variable):
 
     def get(self):
         """Return value of variable as string."""
-        return self._tk.globalgetvar(self._name)
+        value = self._tk.globalgetvar(self._name)
+        if isinstance(value, basestring):
+            return value
+        return str(value)
 
 class IntVar(Variable):
     """Value holder for integer variables."""
@@ -267,7 +270,7 @@ class BooleanVar(Variable):
         Variable.__init__(self, master)
 
     def get(self):
-        """Return the value of the variable as 0 or 1."""
+        """Return the value of the variable as a bool."""
         return self._tk.getboolean(self._tk.globalgetvar(self._name))
 
 def mainloop(n=0):
@@ -369,7 +372,7 @@ class Misc:
     getint = int
     getdouble = float
     def getboolean(self, s):
-        """Return 0 or 1 for Tcl boolean values true and false given as parameter."""
+        """Return a boolean value  for Tcl boolean values true and false given as parameter."""
         return self.tk.getboolean(s)
     def focus_set(self):
         """Direct input focus to this widget.
@@ -1636,7 +1639,7 @@ class Pack:
         anchor=NSEW (or subset) - position widget according to
                                   given direction
                 before=widget - pack it before you will pack widget
-        expand=1 or 0 - expand widget if parent size grows
+        expand=bool - expand widget if parent size grows
         fill=NONE or X or Y or BOTH - fill widget if widget grows
         in=master - use master to contain this widget
         ipadx=amount - add internal padding in x direction
index 5eef5e9104f5e2f838c29bab754a73750467ba46..1e3800b3c26452b871fc8050a85f05dee81ff354 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -63,6 +63,9 @@ Core and builtins
 Extension modules
 -----------------
 
+- Tkinter wrappers around Tcl variables now pass objects directly
+  to Tcl, instead of first converting them to strings.
+
 - The .*? pattern in the re module is now special-cased to avoid the
   recursion limit.  (SF patch #720991 -- many thanks to Gary Herron
   and Greg Chapman.)