Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0de5362

Browse files
Issue #6160: The bbox() method of tkinter.Spinbox now returns a tuple of
integers instead of a string. Based on patch by Guilherme Polo.
2 parents 7df4ddd + 2849e0d commit 0de5362

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
@@ -3472,7 +3472,7 @@ def bbox(self, index):
34723472
bounding box may refer to a region outside the
34733473
visible area of the window.
34743474
"""
3475-
return self.tk.call(self._w, 'bbox', index)
3475+
return self._getints(self.tk.call(self._w, 'bbox', index)) or None
34763476

34773477
def delete(self, first, last=None):
34783478
"""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
@@ -31,6 +31,9 @@ Core and Builtins
3131
Library
3232
-------
3333

34+
- Issue #6160: The bbox() method of tkinter.Spinbox now returns a tuple of
35+
integers instead of a string. Based on patch by Guilherme Polo.
36+
3437
- Issue #19403: contextlib.redirect_stdout is now reentrant
3538

3639
- Issue #19286: Directories in ``package_data`` are no longer added to

0 commit comments

Comments
 (0)