Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.8 kB
8
Indexable
Never
from tkinter import *


class FirstPage(Frame):


    def __init__(self, parent, controller):
        Frame.__init__(self, parent)
        label = Label(self, text = "1 page").pack()
        button = Button(self, text="NEXT", command= lambda : controller.show_frame(SecondPage)).pack()
        button = Button(self, text="BACK", command= lambda : controller.show_frame(ThirdPage)).pack()






class SecondPage(Frame):


    def __init__(self, parent, controller):
        Frame.__init__(self, parent)
        label = Label(self, text = "2 page").pack()
        button = Button(self, text="NEXT", command= lambda : controller.show_frame(ThirdPage)).pack()        
        button = Button(self, text="BACK", command= lambda : controller.show_frame(FirstPage)).pack()






class ThirdPage(Frame):


    def __init__(self, parent, controller):
        Frame.__init__(self, parent)
        label = Label(self, text = "3 page").pack()
        button = Button(self, text="NEXT", command= lambda : controller.show_frame(FirstPage)).pack()
        button = Button(self, text="BACK", command= lambda : controller.show_frame(SecondPage)).pack()






class App(Tk):


    def __init__(self, *args, **kwargs):
        Tk.__init__(self, *args, **kwargs)
        window = Frame(self)
        window.pack()
        window.grid_rowconfigure(0, minsize=500)
        window.grid_columnconfigure(0, minsize=800)

        self.frames = {}
        for F in (FirstPage, SecondPage, ThirdPage):
            frame = F(window, self)
            self.frames[F] = frame
            frame.grid(row=0,column=0, sticky="nsew")

        self.show_frame(FirstPage)
    


    def show_frame(self, page):
        frame = self.frames[page]
        frame.tkraise()







ap = App()
ap.mainloop()