python swap frames

Solutions on MaxInterview for python swap frames by the best coders in the world

showing results for - "python swap frames"
Bruce
31 Jan 2021
1from tkinter import *
2
3def raise_frame(frame):
4    frame.tkraise()
5
6root = Tk()
7
8f1 = Frame(root)
9f2 = Frame(root)
10f3 = Frame(root)
11f4 = Frame(root)
12
13for frame in (f1, f2, f3, f4):
14    frame.grid(row=0, column=0, sticky='news')
15
16Button(f1, text='Go to frame 2', command=lambda:raise_frame(f2)).pack()
17Label(f1, text='FRAME 1').pack()
18
19Label(f2, text='FRAME 2').pack()
20Button(f2, text='Go to frame 3', command=lambda:raise_frame(f3)).pack()
21
22Label(f3, text='FRAME 3').pack(side='left')
23Button(f3, text='Go to frame 4', command=lambda:raise_frame(f4)).pack(side='left')
24
25Label(f4, text='FRAME 4').pack()
26Button(f4, text='Goto to frame 1', command=lambda:raise_frame(f1)).pack()
27
28raise_frame(f1)
29root.mainloop()
queries leading to this page
python swap framespython swap frames