GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-130693: Add options of the tkinter.Text.search method: -nolinestop -all -overlap -strictlimits by sharktide · Pull Request #130848 · python/cpython

Conversation

@sharktide

@sharktide sharktide commented Mar 4, 2025 •
edited by terryjreedy
Loading

Uh oh!

There was an error while loading. Please reload this page.

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

  • Issue: tkinter missing -nolinestop on tk.Text #130693

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

serhiy-storchaka reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@sharktide
Update __init__.py
8b27bcb
@bedevere-app

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added the awaiting review label Mar 4, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Mar 4, 2025
tkinter missing -nolinestop on tk.Text #130693
Closed
blurb-it Bot and others added 2 commits March 4, 2025 17:19
@blurb-it
📜🤖 Added by blurb_it.
18d5005
@sharktide
Update 2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst
e2a76c2
Wulian233
Wulian233 reviewed Mar 5, 2025
View reviewed changes
Comment thread Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@sharktide
Update 2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst
753da3a
@sharktide
sharktide requested a review from Wulian233 March 5, 2025 15:20
@sharktide
Update 2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst
1ca30c6
Wulian233
Wulian233 reviewed May 5, 2025
View reviewed changes
Comment thread Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

sharktide added 2 commits May 5, 2025 11:46
@sharktide
Merge branch 'python:main' into patch-130693
548e36a
@sharktide
pythongh-130693 Remove wordiness; only title left
6ce83e3
@sharktide
sharktide requested a review from Wulian233 May 5, 2025 15:49
@sharktide
Update 2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst
39f5875
@sharktide
sharktide requested a review from ZeroIntensity May 30, 2025 20:09
ZeroIntensity
ZeroIntensity reviewed Jun 17, 2025
View reviewed changes

@ZeroIntensity ZeroIntensity left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/tkinter/__init__.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/tkinter/__init__.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@ZeroIntensity ZeroIntensity added the topic-tkinter label Jun 17, 2025
sharktide and others added 4 commits June 17, 2025 19:13
@sharktide @ZeroIntensity
remove whitespace in Lib/tkinter/__init__.py
ba0c98a
Co-authored-by: Peter Bierma <[email protected]>
@sharktide
Revert formatting in Lib/tkinter/__init__.py
754a124
@sharktide @ZeroIntensity
Update news entry to use :meth: tags
ffd95fa
Co-authored-by: Peter Bierma <[email protected]>
@sharktide
Merge branch 'main' into patch-130693
72e70fc
ZeroIntensity
ZeroIntensity reviewed Jun 17, 2025
View reviewed changes
Comment thread Misc/NEWS.d/next/Library/2025-03-04-17-19-26.gh-issue-130693.Kv01r8.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

sharktide and others added 3 commits June 17, 2025 21:50
@sharktide @ZeroIntensity
Remove newlines in news entry
6229bdf
Co-authored-by: Peter Bierma <[email protected]>
@sharktide
Remove ref to nonexistent docs (needs to be fixed later)
1843da6
@sharktide
Use double backticks in news entry
7196a88
@ZeroIntensity

ZeroIntensity commented Jun 17, 2025

Copy link
Copy Markdown
Member

Thanks! Shoot for the stars :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

sharktide added 3 commits June 18, 2025 09:49
@sharktide
Add test cases to test_text.py
2601ddf
@sharktide
Fix test failures due to return type being tcl obj not tuple
6d18d2f
@sharktide
Make linter happy
b672353
@sharktide
sharktide requested a review from serhiy-storchaka August 11, 2025 20:17
@sharktide
Merge branch 'main' into patch-130693
9604fcb
serhiy-storchaka
serhiy-storchaka reviewed Sep 2, 2025
View reviewed changes
Comment thread Doc/whatsnew/3.15.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_tkinter/test_text.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_tkinter/test_text.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/whatsnew/3.15.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@sharktide
Remove unrelated change
0e50ded
@python-cla-bot

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

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

sharktide added 6 commits November 16, 2025 10:40
@sharktide
Remove unrelated changes python#2
6ef05e3
@sharktide
Enhance regex tests for text widget
c0b7772
Added tests for text.search with and without regex.
@sharktide
Simplify test_search_all assertions in test_text.py
342a19c
Refactor test_search_all to simplify assertions and update overlap checks.
@sharktide
Update test assertion for search_all method
64b9930
@sharktide
Remove nolinestop parameter from text.search
caceee3
@sharktide
Merge branch 'main' into patch-130693
37577eb
@sharktide
sharktide requested a review from serhiy-storchaka November 16, 2025 16:20
@sharktide

sharktide commented Nov 16, 2025

Copy link
Copy Markdown
Contributor Author

@serhiy-storchaka Ready for review

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

sharktide and others added 6 commits November 16, 2025 11:33
@sharktide
Fix expected results in search_all test case
7e331be
@sharktide
Remove unnecessary comment
1f64ef2
@serhiy-storchaka
Improve tests.
b40b474
@serhiy-storchaka
Add more tests.
bc1685b
@serhiy-storchaka
Make new parameters keyword-only.
d675252
@serhiy-storchaka
Add more tests. Only ignore stopindex if it is None.
e145e60
@serhiy-storchaka
serhiy-storchaka enabled auto-merge (squash) November 17, 2025 14:10
@serhiy-storchaka
serhiy-storchaka merged commit 3d14805 into python:main Nov 17, 2025
46 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting review label Nov 17, 2025
serhiy-storchaka pushed a commit to serhiy-storchaka/cpython that referenced this pull request Nov 17, 2025
@sharktide @serhiy-storchaka
pythongh-130693: Add more tests for tkinter.Text.search() (pythonGH-1…
93cdf3f
…30848)
@bedevere-app

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@serhiy-storchaka

serhiy-storchaka commented Nov 17, 2025

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

serhiy-storchaka added a commit that referenced this pull request Nov 17, 2025
@serhiy-storchaka
[3.14] gh-130693: Add more tests for tkinter.Text.search() (GH-130848) (
8db1aad
GH-141669)
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 17, 2025
@serhiy-storchaka @miss-islington
[3.14] pythongh-130693: Add more tests for tkinter.Text.search() (pyt…
90a86c4
…honGH-130848) (pythonGH-141669)

(cherry picked from commit 8db1aad)

Co-authored-by: Serhiy Storchaka <[email protected]>
serhiy-storchaka added a commit that referenced this pull request Nov 17, 2025
@miss-islington @serhiy-storchaka
[3.13] gh-130693: Add more tests for tkinter.Text.search() (GH-130848) (
0280744
GH-141669) (GH-141670)

(cherry picked from commit 8db1aad)

Co-authored-by: Serhiy Storchaka <[email protected]>
StanFromIreland pushed a commit to StanFromIreland/cpython that referenced this pull request Dec 6, 2025
@sharktide @StanFromIreland
pythongh-130693: Support more options for search in tkinter.Text (pyt…
6467f73
…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.
@JelleZijlstra JelleZijlstra mentioned this pull request May 8, 2026
Python 3.15: sort allowlists, more small updates python/typeshed#15714
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ZeroIntensity ZeroIntensity ZeroIntensity left review comments
@AA-Turner AA-Turner Awaiting requested review from AA-Turner AA-Turner is a code owner
@serhiy-storchaka serhiy-storchaka Awaiting requested review from serhiy-storchaka
+2 more reviewers
@Wulian233 Wulian233 Wulian233 left review comments
@Xiaokang2022 Xiaokang2022 Xiaokang2022 left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

topic-tkinter

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

tkinter missing -nolinestop on tk.Text

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@sharktide @ZeroIntensity @Wulian233 @serhiy-storchaka @Xiaokang2022
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.