FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-130693: Add options of the tkinter.Text.search method: -nolinestop -all -overlap -strictlimits by sharktide · Pull Request #130848 · python/cpython · GitHub

Repository navigation

gh-130693: Add options of the tkinter.Text.search method: -nolinestop -all -overlap -strictlimits - #130848

Merged
serhiy-storchaka merged 57 commits into
python:mainfrom
sharktide:patch-130693
Nov 17, 2025
Merged

serhiy-storchaka merged 57 commits into
python:mainfrom
sharktide:patch-130693

Conversation

sharktide commented Mar 4, 2025 •
edited by terryjreedy
Loading

Copy link
Copy Markdown
Contributor

Add options -nolinestop, -all, -overlap, and -strictlimits to the search function of the text class of tkinter.

Fixes #130693
Closes #130693

Tested against

.\PCbuild\amd64\python_d.exe -m test -ugui test_tkinter

And test passed. Result:

0:00:00 [1/1] test_tkinter
0:00:27 load avg: 3.93 [1/1] test_tkinter passed

== Tests result: SUCCESS ==

1 test OK.

Total duration: 27.6 sec
Total tests: run=787 skipped=11
Total test files: run=1/1
Result: SUCCESS

Also tested against a custom test file:
[EDITED for change to new search_all method for -all and -overlap]

import tkinter as tk

root = tk.Tk()
text = tk.Text(root)
text.pack()

text.insert('1.0', 'This is a test. This is only a test.\nAnother line.\nYet another line.')

# Test without options
result = text.search('test', '1.0', 'end')
print('Without options:', result)

# Test with -nolinestop
result = text.search('line', '1.0', 'end', nolinestop=True, regexp=True)
print('With -nolinestop:', result)

# Test with search_all
result = text.search_all('test', '1.0', 'end')
print('With search_all:', result)

# Test with -overlap
result = text.search_all('test', '1.0', 'end', overlap=True)
print('With -overlap:', result)

# Test with -strictlimits
result = text.search('test', '1.0', 'end', strictlimits=True)
print('With -strictlimits:', result)

root.mainloop()

Which returns:

Without options: 1.10
With -nolinestop: 2.8
With search_all: (<textindex object: '1.10'>, <textindex object: '1.31'>)
With -overlap: (<textindex object: '1.10'>, <textindex object: '1.31'>)
With -strictlimits: 1.10

Indicating that the new features are functioning correctly

bedevere-app Bot commented Mar 4, 2025

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

sharktide requested a review from Wulian233 March 5, 2025 15:20
sharktide requested a review from Wulian233 May 5, 2025 15:49
sharktide requested a review from ZeroIntensity May 30, 2025 20:09

ZeroIntensity left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

All new features need tests. Please add one to test_tkinter.

Comment thread Lib/tkinter/__init__.py Outdated
Comment thread Lib/tkinter/__init__.py Outdated

Copy link
Copy Markdown
Member

Thanks! Shoot for the stars :)

Comment thread Doc/whatsnew/3.15.rst
Comment thread Lib/test/test_tkinter/test_text.py Outdated
Comment thread Lib/test/test_tkinter/test_text.py Outdated
Comment thread Doc/whatsnew/3.15.rst Outdated

python-cla-bot Bot commented Nov 16, 2025 •
edited
Loading

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

Copy link
Copy Markdown
Contributor Author

@serhiy-storchaka Ready for review

serhiy-storchaka enabled auto-merge (squash) November 17, 2025 14:10
serhiy-storchaka merged commit 3d14805 into python:main Nov 17, 2025
46 checks passed
serhiy-storchaka pushed a commit to serhiy-storchaka/cpython that referenced this pull request Nov 17, 2025

bedevere-app Bot commented Nov 17, 2025

Copy link
Copy Markdown

GH-141669 is a backport of this pull request to the 3.14 branch.

Copy link
Copy Markdown
Member

Thank you for your contribution, @sharktide. I rewrote the tests, so they clearly test the new options, and added many tests for already supported options. These tests will be backported.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 17, 2025
…honGH-130848) (pythonGH-141669)

(cherry picked from commit 8db1aad)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
serhiy-storchaka added a commit that referenced this pull request Nov 17, 2025
GH-141669) (GH-141670)

(cherry picked from commit 8db1aad)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
StanFromIreland pushed a commit to StanFromIreland/cpython that referenced this pull request Dec 6, 2025
…honGH-130848)

* Add parameters nolinestop and strictlimits in the tkinter.Text.search() method.
* Add the tkinter.Text.search_all() method.
* Add more tests for tkinter.Text.search().
* stopindex is now only ignored if it is None.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tkinter missing -nolinestop on tk.Text

5 participants


Back | FazBrowse Home | New Git URL