Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # tk_page_flip_frames.py
- from tkinter import *
- root = Tk()
- root.title('tk Page Flip Frames')
- root.geometry('500x250+300+300')
- # Position frame
- frame = LabelFrame(root, text='Press Button To Select A Frame', padx=25, pady=25)
- frame.pack(padx=10, pady=50)
- # What do the buttons do
- def xyz(frame):
- frame.destroy()
- frame = LabelFrame(root, text='Frame XYZ', padx=25, pady=25)
- frame.pack(padx=10, pady=50)
- theFrame = Label(frame, text='XYZ Has Been Chosen')
- theFrame.grid(row=0, column=0, columnspan=2)
- back(frame)
- def abc(frame):
- frame.destroy()
- frame = LabelFrame(root, text='Frame ABC', padx=25, pady=25)
- frame.pack(padx=10, pady=50)
- theFrame = Label(frame, text='ABC Has Been Chosen')
- theFrame.grid(row=0, column=0, columnspan=2)
- back(frame)
- def back(frame):
- # Option to go back
- homepage = Button(frame, text='BACK', command=lambda:mainframe(frame))
- homepage.grid(row=1, column=0, columnspan=2, pady=10)
- def mainframe(frame):
- frame.destroy()
- frame = LabelFrame(root, text='The Main Frame', padx=25, pady=25)
- frame.pack(padx=10, pady=50)
- # Create the buttons and put them in the frame
- b = Button(frame, text="XYZ", fg='red', command=lambda:xyz(frame))
- b2 = Button(frame, text='ABC', fg='green', command=lambda:abc(frame))
- b.grid(row=0, column=0, padx=3)
- b2.grid(row=0, column=1, padx=3)
- mainframe(frame)
- root.mainloop()
Add Comment
Please, Sign In to add comment