importtkinterastkfromtkinterimportttkLARGEFONT=("Verdana",35)classtkinterApp(tk.Tk):# __init__ function for class tkinterAppdef__init__(self,*args,**kwargs):# __init__ function for class Tktk.Tk.__init__(self,*args,**kwargs)# creating a containercontainer=tk.Frame(self)container.pack(side="top",fill="both",expand=True)container.grid_rowconfigure(0,weight=1)container.grid_columnconfigure(0,weight=1)# initializing frames to an empty arrayself.frames={}# iterating through a tuple consisting# of the different page layoutsforFin(StartPage,Page1,Page2):frame=F(container,self)# initializing frame of that object from# startpage, page1, page2 respectively with# for loopself.frames[F]=frameframe.grid(row=0,column=0,sticky="nsew")self.show_frame(StartPage)# to display the current frame passed as# parameterdefshow_frame(self,cont):frame=self.frames[cont]frame.tkraise()# first window frame startpageclassStartPage(tk.Frame):def__init__(self,parent,controller):tk.Frame.__init__(self,parent)# label of frame Layout 2label=ttk.Label(self,text="Startpage",font=LARGEFONT)# putting the grid in its place by using# gridlabel.grid(row=0,column=4,padx=10,pady=10)button1=ttk.Button(self,text="Page 1",command=lambda:controller.show_frame(Page1))# putting the button in its place by# using gridbutton1.grid(row=1,column=1,padx=10,pady=10)## button to show frame 2 with text layout2button2=ttk.Button(self,text="Page 2",command=lambda:controller.show_frame(Page2))# putting the button in its place by# using gridbutton2.grid(row=2,column=1,padx=10,pady=10)# second window frame page1classPage1(tk.Frame):def__init__(self,parent,controller):tk.Frame.__init__(self,parent)label=ttk.Label(self,text="Page 1",font=LARGEFONT)label.grid(row=0,column=4,padx=10,pady=10)# button to show frame 2 with text# layout2button1=ttk.Button(self,text="StartPage",command=lambda:controller.show_frame(StartPage))# putting the button in its place# by using gridbutton1.grid(row=1,column=1,padx=10,pady=10)# button to show frame 2 with text# layout2button2=ttk.Button(self,text="Page 2",command=lambda:controller.show_frame(Page2))# putting the button in its place by# using gridbutton2.grid(row=2,column=1,padx=10,pady=10)# third window frame page2classPage2(tk.Frame):def__init__(self,parent,controller):tk.Frame.__init__(self,parent)label=ttk.Label(self,text="Page 2",font=LARGEFONT)label.grid(row=0,column=4,padx=10,pady=10)# button to show frame 2 with text# layout2button1=ttk.Button(self,text="Page 1",command=lambda:controller.show_frame(Page1))# putting the button in its place by# using gridbutton1.grid(row=1,column=1,padx=10,pady=10)# button to show frame 3 with text# layout3button2=ttk.Button(self,text="Startpage",command=lambda:controller.show_frame(StartPage))# putting the button in its place by# using gridbutton2.grid(row=2,column=1,padx=10,pady=10)# Driver Codeapp=tkinterApp()app.mainloop()