summaryrefslogtreecommitdiffstats
path: root/Lib/tkinter/__init__.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-10-30 16:52:02 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-10-30 16:52:02 (GMT)
commit016a9acb2603f07866c060cb14b655b9d9b822fa (patch)
treeaadf86d83353c7be1fcbed3667e6be084d15ce44 /Lib/tkinter/__init__.py
parent998c9cdd423409e2b40e02eb41614536f9d8005c (diff)
parent32c0d3ada52109f339c081d3408546a4af024b3c (diff)
downloadcpython-016a9acb2603f07866c060cb14b655b9d9b822fa.zip
cpython-016a9acb2603f07866c060cb14b655b9d9b822fa.tar.gz
cpython-016a9acb2603f07866c060cb14b655b9d9b822fa.tar.bz2
Issue #27939: Fixed bugs in tkinter.ttk.LabeledScale and tkinter.Scale caused
by representing the scale as float value internally in Tk. tkinter.IntVar now works if float value is set to underlying Tk variable.
Diffstat (limited to 'Lib/tkinter/__init__.py')
-rw-r--r--Lib/tkinter/__init__.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py
index 25fe645..ee2415d 100644
--- a/Lib/tkinter/__init__.py
+++ b/Lib/tkinter/__init__.py
@@ -500,7 +500,11 @@ class IntVar(Variable):
def get(self):
"""Return the value of the variable as an integer."""
- return self._tk.getint(self._tk.globalgetvar(self._name))
+ value = self._tk.globalgetvar(self._name)
+ try:
+ return self._tk.getint(value)
+ except (TypeError, TclError):
+ return int(self._tk.getdouble(value))
class DoubleVar(Variable):
"""Value holder for float variables."""
@@ -3003,7 +3007,7 @@ class Scale(Widget):
value = self.tk.call(self._w, 'get')
try:
return self.tk.getint(value)
- except (ValueError, TclError):
+ except (ValueError, TypeError, TclError):
return self.tk.getdouble(value)
def set(self, value):
"""Set the value to VALUE."""