Tkinter has low-level events, such as <Visibility> and <Map> which should fire when pages change. Unfortunately, they do not work reliably on all platforms.
The simplest and most reliable solution is to create your own event. You can create and bind a custom event by specifying the event inside << and >> (for example: <<ShowFrame>> ).
First change show_frame to send an event to the window when it is displayed:
def show_frame(self, page_name): ... frame.event_generate("<<ShowFrame>>")
Further, each page can be attached to this event if it should be notified when it becomes visible:
class UploadPage(tk.Frame): def __init__(self, parent, controller): ... self.bind("<<ShowFrame>>", self.on_show_frame) def on_show_frame(self, event): print("I am being shown...")
Bryan Oakley Jan 27 '16 at 11:35 2016-01-27 11:35
source share