0
from tkinter import *

def raise_frame(frame):
    frame.tkraise()

root = Tk()

f1 = Frame(root)
f2 = Frame(root)
f3 = Frame(root)
f4 = Frame(root)

for frame in (f1, f2, f3, f4):
    frame.grid(row=0, column=0, sticky='news')

Button(f1, text='Go to frame 2', command=lambda:raise_frame(f2)).pack()
Label(f1, text='FRAME 1').pack()

Label(f2, text='FRAME 2').pack()
Button(f2, text='Go to frame 3', command=lambda:raise_frame(f3)).pack()

Label(f3, text='FRAME 3').pack(side='left')
Button(f3, text='Go to frame 4', command=lambda:raise_frame(f4)).pack(side='left')

Label(f4, text='FRAME 4').pack()
Button(f4, text='Goto to frame 1', command=lambda:raise_frame(f1)).pack()

raise_frame(f1)
root.mainloop

I was able to run other code but this one wouldn't load I don't know why.

1
  • You forgot your () after root.mainloop Commented Apr 10, 2021 at 16:23

1 Answer 1

2

The last statement isn't calling mainloop — it should be:

...
raise_frame(f1)
root.mainloop()  # Note `()` at end.
Sign up to request clarification or add additional context in comments.

3 Comments

Oops, I should have read the answers before commenting!
@RufusVSL You can delete your comments…
I tend to leave my mistakes on file as a humbling cautionary tale for myself and others.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.