O'Reilly logo

Tkinter GUI Programming by Example by David Love

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using our FindWindow class

As you may have guessed, the FindWindow class needs to be imported at the beginning of the file:

from findwindow import FindWindow

Now, we need to create an instance whenever the user presses a key combination. Typically, a Find and Replace window appears on Ctrl and F or Ctrl and R. I will use Ctrl and F for this application:

def bind_events(self):    ...    self.bind('<Control-f>', self.show_find_window)def show_find_window(self, event=None):    FindWindow(self.text_area)

A method called show_find_window is created, which will be responsible for showing our FindWindow popup.

Inside this method, all we need to do is instantiate the FindWindow class, passing it our TextArea to act as its master. The Toplevel class which ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required