Skip to content

Commit 2849e0d

Browse files
Issue python#6160: The bbox() method of tkinter.Spinbox now returns a tuple of
integers instead of a string. Based on patch by Guilherme Polo.
1 parent 0bdcdec commit 2849e0d

3 files changed

Lines changed: 16 additions & 1 deletion

File tree

‎Lib/tkinter/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3511,7 +3511,7 @@ def bbox(self, index):
35113511
bounding box may refer to a region outside the
35123512
visible area of the window.
35133513
"""
3514-
return self.tk.call(self._w, 'bbox', index)
3514+
return self._getints(self.tk.call(self._w, 'bbox', index)) or None
35153515

35163516
def delete(self, first, last=None):
35173517
"""Delete one or more elements of the spinbox.

‎Lib/tkinter/test/test_tkinter/test_widgets.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,18 @@ def test_wrap(self):
457457
widget = self.create()
458458
self.checkBooleanParam(widget, 'wrap')
459459

460+
def test_bbox(self):
461+
widget = self.create()
462+
bbox = widget.bbox(0)
463+
self.assertEqual(len(bbox), 4)
464+
for item in bbox:
465+
self.assertIsInstance(item, int)
466+
467+
self.assertRaises(tkinter.TclError, widget.bbox, 'noindex')
468+
self.assertRaises(tkinter.TclError, widget.bbox, None)
469+
self.assertRaises(TypeError, widget.bbox)
470+
self.assertRaises(TypeError, widget.bbox, 0, 1)
471+
460472

461473
@add_standard_options(StandardOptionsTests)
462474
class TextTest(AbstractWidgetTest, unittest.TestCase):

‎Misc/NEWS‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ Core and Builtins
1313
Library
1414
-------
1515

16+
- Issue #6160: The bbox() method of tkinter.Spinbox now returns a tuple of
17+
integers instead of a string. Based on patch by Guilherme Polo.
18+
1619
- Issue #19286: Directories in ``package_data`` are no longer added to
1720
the filelist, preventing failure outlined in the ticket.
1821

0 commit comments

Comments
 (0)