summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuliette Monsel <j4321@users.noreply.github.com>2018-10-18 19:28:31 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2018-10-18 19:28:31 (GMT)
commit1deea5e53991b46351f6bb395b22365c9455ed88 (patch)
treeff06edbf2cb6330de85e5f713355b1ff1453d92a
parentbbd90e4f6273f1c29c03ab1374fdbd1a862fc14a (diff)
downloadcpython-1deea5e53991b46351f6bb395b22365c9455ed88.zip
cpython-1deea5e53991b46351f6bb395b22365c9455ed88.tar.gz
cpython-1deea5e53991b46351f6bb395b22365c9455ed88.tar.bz2
bpo-34936: Fix TclError in tkinter.Spinbox.selection_element(). (GH-9760)
-rw-r--r--Lib/tkinter/__init__.py8
-rw-r--r--Lib/tkinter/test/test_tkinter/test_widgets.py9
-rw-r--r--Misc/NEWS.d/next/Library/2018-10-08-21-05-11.bpo-34936.3tRqdq.rst2
3 files changed, 14 insertions, 5 deletions
diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py
index 1dc4118..ae493ed 100644
--- a/Lib/tkinter/__init__.py
+++ b/Lib/tkinter/__init__.py
@@ -4280,7 +4280,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)
@@ -4288,7 +4288,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")
@@ -4296,9 +4296,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)
def selection_from(self, index):
"""Set the fixed end of a selection to INDEX."""
diff --git a/Lib/tkinter/test/test_tkinter/test_widgets.py b/Lib/tkinter/test/test_tkinter/test_widgets.py
index 12a0fbe..16e9d93 100644
--- a/Lib/tkinter/test/test_tkinter/test_widgets.py
+++ b/Lib/tkinter/test/test_tkinter/test_widgets.py
@@ -522,7 +522,14 @@ class SpinboxTest(EntryTest, unittest.TestCase):
self.assertEqual(widget.selection_get(), '2345')
widget.selection_adjust(0)
self.assertEqual(widget.selection_get(), '12345')
- widget.selection_adjust(0)
+
+ 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)
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
index 0000000..7c1f7bb
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2018-10-08-21-05-11.bpo-34936.3tRqdq.rst
@@ -0,0 +1,2 @@
+Fix ``TclError`` in ``tkinter.Spinbox.selection_element()``. Patch by
+Juliette Monsel.