Implementing the Find Text feature
Next, let's code the Find Text
feature (refer to 2.05.py
in the code bundle). The following screenshot shows an example of the Find Text
feature:
Here's a quick summary of the desired functionality. When a user clicks on the Find menu item, a new Toplevel window opens up. The user enters a search keyword and specifies whether the search needs to be case-sensitive. When the user clicks on the Find All button, all matches are highlighted.
To search through the document, we will rely on the text_widget.search()
method. The search
method takes in the following arguments:
search(pattern, startindex, stopindex=None, forwards=None, ...
Get Tkinter GUI Application Development Blueprints now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.