Skip to content

bpo-34936: Fix TclError in tkinter.Spinbox.selection_element() #9760

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Oct 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Lib/tkinter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3750,25 +3750,25 @@ def selection_adjust(self, index):
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)

def selection_clear(self):
"""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")

def selection_element(self, element=None):
"""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."""
Expand Down
9 changes: 8 additions & 1 deletion Lib/tkinter/test/test_tkinter/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,14 @@ def test_selection_methods(self):
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)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix ``TclError`` in ``tkinter.Spinbox.selection_element()``. Patch by
Juliette Monsel.