I have this frame that is displayed however, I want the last line to run only when this frame is actually shown (and not when the program runs). Things are happening in the function start which I only want happening when this frame is shown
class FrameTwo(reviseTen):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
self.instructions = tk.Label(self, text="Click on the option you think is correct, then click 'Proceed to next question'")
self.startButton = tk.Button(self, text="Click here to start revision session")
self.optionOne = tk.Button(self, text="Option One", command=super(FrameTwo, self).clickOptionOne)
self.optionTwo = tk.Button(self, text="Option Two", command=super(FrameTwo, self).clickOptionTwo)
self.optionThree = tk.Button(self, text="Option Three", command=super(FrameTwo, self).clickOptionThree)
self.optionFour = tk.Button(self, text="Option Four", command=super(FrameTwo, self).clickOptionFour)
self.question = tk.Label(self, text="What is the definition of: ")
self.proceedButton = tk.Button(self, text="Proceed to next question", command=lambda: controller.show_frame(FrameThree))
############# EDIT ####################
self.bind("<<Show>>", self.do_something)
def do_something(self, event):
self.start()
EDIT Here is my show_frame method:
def show_frame(self, cont): # Method to show the current frame being used
for frame in self.frames.values():
frame.grid_remove()
frame = self.frames[cont]
frame.tkraise()
frame.update()
frame.grid()
frame.event_generate("<<Show>>")