mirror of
https://github.com/python/cpython.git
synced 2025-11-01 10:45:30 +00:00
gh-97928: Partially restore the behavior of tkinter.Text.count() by default (GH-115031)
By default, it preserves an inconsistent behavior of older Python versions: packs the count into a 1-tuple if only one or none options are specified (including 'update'), returns None instead of 0. Except that setting wantobjects to 0 no longer affects the result. Add a new parameter return_ints: specifying return_ints=True makes Text.count() always returning the single count as an integer instead of a 1-tuple or None.
This commit is contained in:
parent
5d2794a16b
commit
d2c4baa41f
5 changed files with 59 additions and 28 deletions
|
|
@ -27,7 +27,7 @@ def get_displaylines(text, index):
|
|||
"""Display height, in lines, of a logical line in a Tk text widget."""
|
||||
return text.count(f"{index} linestart",
|
||||
f"{index} lineend",
|
||||
"displaylines")
|
||||
"displaylines", return_ints=True)
|
||||
|
||||
def get_widget_padding(widget):
|
||||
"""Get the total padding of a Tk widget, including its border."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue