]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[2.7] bpo-34936: Fix TclError in tkinter.Spinbox.selection_element(). (GH-9760) ...
authorSerhiy Storchaka <storchaka@gmail.com>
Sun, 21 Oct 2018 07:10:24 +0000 (10:10 +0300)
committerGitHub <noreply@github.com>
Sun, 21 Oct 2018 07:10:24 +0000 (10:10 +0300)
(cherry picked from commit 1deea5e53991b46351f6bb395b22365c9455ed88).
(cherry picked from commit bd9c2ce7acaef45f23c2659b854fc9925096d040)

Co-authored-by: Juliette Monsel <j4321@users.noreply.github.com>
Lib/lib-tk/Tkinter.py
Lib/lib-tk/test/test_tkinter/test_widgets.py
Misc/NEWS.d/next/Library/2018-10-08-21-05-11.bpo-34936.3tRqdq.rst [new file with mode: 0644]

index 2f3a3f12a51227238256217bc3b3cb694aee5501..6c02955928ecd99e9482d4f756f3b5643c7471cf 100644 (file)
@@ -3582,7 +3582,7 @@ class Spinbox(Widget, XView):
         select to commands. If the selection isn't currently in
         the spinbox, then a new selection is created to include
         the characters between index and the most recent selection
-        anchor point, inclusive. Returns an empty string.
+        anchor point, inclusive.
         """
         return self.selection("adjust", index)
 
@@ -3590,7 +3590,7 @@ class Spinbox(Widget, XView):
         """Clear the selection
 
         If the selection isn't in this widget then the
-        command has no effect. Returns an empty string.
+        command has no effect.
         """
         return self.selection("clear")
 
@@ -3598,9 +3598,9 @@ class Spinbox(Widget, XView):
         """Sets or gets the currently selected element.
 
         If a spinbutton element is specified, it will be
-        displayed depressed
+        displayed depressed.
         """
-        return self.selection("element", element)
+        return self.tk.call(self._w, 'selection', 'element', element)
 
 ###########################################################################
 
index db2cd9db2430e9658a5930521ed81c81dc31a0fd..4b196ac5d510c3ad7b1317106ec3d7f6604282d2 100644 (file)
@@ -471,6 +471,14 @@ class SpinboxTest(EntryTest, unittest.TestCase):
         self.assertRaises(TypeError, widget.bbox)
         self.assertRaises(TypeError, widget.bbox, 0, 1)
 
+    def test_selection_element(self):
+        widget = self.create()
+        self.assertEqual(widget.selection_element(), "none")
+        widget.selection_element("buttonup")
+        self.assertEqual(widget.selection_element(), "buttonup")
+        widget.selection_element("buttondown")
+        self.assertEqual(widget.selection_element(), "buttondown")
+
 
 @add_standard_options(StandardOptionsTests)
 class TextTest(AbstractWidgetTest, unittest.TestCase):
diff --git a/Misc/NEWS.d/next/Library/2018-10-08-21-05-11.bpo-34936.3tRqdq.rst b/Misc/NEWS.d/next/Library/2018-10-08-21-05-11.bpo-34936.3tRqdq.rst
new file mode 100644 (file)
index 0000000..7c1f7bb
--- /dev/null
@@ -0,0 +1,2 @@
+Fix ``TclError`` in ``tkinter.Spinbox.selection_element()``. Patch by
+Juliette Monsel.