summaryrefslogtreecommitdiffstats
path: root/Lib/tkinter/test/test_ttk
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/test/test_ttk
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/test/test_ttk')
-rw-r--r--Lib/tkinter/test/test_ttk/test_extensions.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/Lib/tkinter/test/test_ttk/test_extensions.py b/Lib/tkinter/test/test_ttk/test_extensions.py
index f33945c..218b27f 100644
--- a/Lib/tkinter/test/test_ttk/test_extensions.py
+++ b/Lib/tkinter/test/test_ttk/test_extensions.py
@@ -69,14 +69,12 @@ class LabeledScaleTest(AbstractTkTest, unittest.TestCase):
# variable initialization/passing
passed_expected = (('0', 0), (0, 0), (10, 10),
- (-1, -1), (sys.maxsize + 1, sys.maxsize + 1))
+ (-1, -1), (sys.maxsize + 1, sys.maxsize + 1),
+ (2.5, 2), ('2.5', 2))
for pair in passed_expected:
x = ttk.LabeledScale(self.root, from_=pair[0])
self.assertEqual(x.value, pair[1])
x.destroy()
- x = ttk.LabeledScale(self.root, from_='2.5')
- self.assertRaises((ValueError, tkinter.TclError), x._variable.get)
- x.destroy()
x = ttk.LabeledScale(self.root, from_=None)
self.assertRaises((ValueError, tkinter.TclError), x._variable.get)
x.destroy()
@@ -155,8 +153,10 @@ class LabeledScaleTest(AbstractTkTest, unittest.TestCase):
# The following update is needed since the test doesn't use mainloop,
# at the same time this shouldn't affect test outcome
x.update()
+ self.assertEqual(x.value, newval)
self.assertEqual(x.label['text'],
newval if self.wantobjects else str(newval))
+ self.assertEqual(float(x.scale.get()), newval)
self.assertGreater(x.scale.coords()[0], curr_xcoord)
self.assertEqual(x.scale.coords()[0],
int(x.label.place_info()['x']))
@@ -168,10 +168,19 @@ class LabeledScaleTest(AbstractTkTest, unittest.TestCase):
conv = int
x.value = conv(x.scale['to']) + 1 # no changes shouldn't happen
x.update()
+ self.assertEqual(x.value, newval)
self.assertEqual(conv(x.label['text']), newval)
+ self.assertEqual(float(x.scale.get()), newval)
self.assertEqual(x.scale.coords()[0],
int(x.label.place_info()['x']))
+ # non-integer value
+ x.value = newval = newval + 1.5
+ x.update()
+ self.assertEqual(x.value, int(newval))
+ self.assertEqual(conv(x.label['text']), int(newval))
+ self.assertEqual(float(x.scale.get()), newval)
+
x.destroy()