0

I want my start_button (labeled "End" on the start_frame) to bring the end_frame to the front. This should display the end_button (labeled "Start" on the end_frame).

I then want the end_button (labeled "Start") to bring the user back to the start_frame by lifting it to the top.

This would basically toggle the start_frame and the end_frame by bringing either one to the top using the buttons.

However, my lift() function isn't moving things to the top. I know lift() can't move children frames above their parents, but I don't think I made that mistake. Where am I going wrong?

import Tkinter as tk

root = tk.Tk()
root.geometry("400x400")

#create main frame for window. This will hold all pages of the menu.
container = tk.Frame(root)
container.pack(side="top", fill="both", expand=True)
container.grid_rowconfigure(0, weight=1)
container.grid_columnconfigure(0, weight=1)

#create subframes
start_frame = tk.Frame(container)
start_frame.grid(row=0, column=0, sticky="nsew", in_ = container)

end_frame = tk.Frame(container)
end_frame.grid(row=0, column=0, sticky="nsew", in_ = container)

#create UI widgets for subframew
start_button = tk.Button(start_frame, text="End", fg="blue", command = end_frame.lift())
start_button.pack(side = tk.BOTTOM)

end_button = tk.Button(end_frame, text="Start", fg="blue", command = start_frame.lift())
end_button.pack(side = tk.BOTTOM)



root.mainloop()

EDIT : I have tried calling start_button.lift() and end_button.lift(), but it gives me the same result.

  • Change the `command = end_frame.lift()` to `command = end_frame.lift` because otherwise you're actually calling it in the `Button` constructor call (and since it probably returns `None`, that's what gets assigned to the `command` attribute). – martineau Apr 17 '18 at 02:54
  • ah god I'm dumb. You ever look at something for forever and you just accept that your syntax is okay. Thank you. – Thomas Beirne Apr 17 '18 at 02:59
  • Don't feel too bad, it's a fairly common mistake...I just felt it was easier to tell you the problem instead of looking up a duplicate question. – martineau Apr 17 '18 at 03:02

0 Answers0