Implementing the Find Text feature

Next, let's code the Find Text feature (refer to in the code bundle). The following screenshot shows an example of the Find Text feature:

Implementing 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 method. The search method takes in the following arguments:

search(pattern, startindex, stopindex=None, forwards=None, ...

Get Tkinter GUI Application Development Blueprints now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.