I am trying to create something in python. I am new in python. I have these frames, each frame will open when a special button is clicked. frames are opened one after each other. I want to open the final page when button 1 of first frame and button 1 of second frame are clicked. can anyone help me? Here is he code:
import tkinter as tk
LARGE_FONT="Verdana",16,"Bold"
MEDIUM_FONT="Verdana Bold"
class SeaofBTCapp(tk.Tk):
def __init__(self,*args,**kwargs):
tk.Tk.__init__(self)
container=tk.Frame(self)
container.pack(side="top",fill="both",expand=True)
container.grid_rowconfigure(0,weight=1)
container.grid_columnconfigure(0,weight=1)
self.frames={}
for F in (StartPage,firstPage,secondPage, thirdPage,):
frame=F(container,self)
self.frames[F]=frame
frame.grid(row=0,column=0,sticky="nsew")
self.show_frame(StartPage)
def show_frame(self,cont):
frame=self.frames[cont]
frame.tkraise()
def qf(param):
print(param)
class StartPage(tk.Frame):
def __init__(self,parent,controller):
tk.Frame.__init__(self,parent)
button1=tk.Button(self,text="START",
command=lambda : controller.show_frame(firstPage))
button1.pack()
def OnButtonClick( button_id):
if (button_id == 11 and button_id==21):
#if button 11 and 21 were clicked I want to show the final page frame not thiird page frame
class firstPage(tk.Frame):
def __init__(self,parent,controller):
tk.Frame.__init__(self,parent)
label1=tk.Label(self,width=50,text="Label one:",bg="#362458",fg="#FFFFFF")
label1.grid(row=2,pady=10,padx=10)
button1=tk.Button(self,text="Button 1",width=8,bg="#362458",fg="#FFFFFF",borderwidth=2, relief="solid",
command=lambda : [controller.show_frame(secondPage),OnButtonClick(11)])
button1.grid(row=4,pady=10,padx=10)
button2=tk.Button(self,text="Button 2",width=8,bg="#362458",fg="#FFFFFF",borderwidth=2, relief="solid",
command=lambda : [controller.show_frame(secondPage),OnButtonClick(12)])
button2.grid(row=6,pady=10,padx=10)
class secondPage(tk.Frame):
def __init__(self,parent,controller):
tk.Frame.__init__(self,parent)
label1=tk.Label(self,width=50,text="Label 2",bg="#362458",fg="#FFFFFF")
label1.grid(row=2,pady=10,padx=10)
button1=tk.Button(self,text="Button 1",width=8,bg="#362458",fg="#FFFFFF",borderwidth=2, relief="solid",
command=lambda : [controller.show_frame(thirdPage),OnButtonClick(21)])
button1.grid(row=4,pady=10,padx=10)
button2=tk.Button(self,text="Button 2",width=8,bg="#362458",fg="#FFFFFF",borderwidth=2, relief="solid",
command=lambda : [controller.show_frame(thirdPage),OnButtonClick(22)])
button2.grid(row=6,pady=10,padx=10)
class thirdPage(tk.Frame):
def __init__(self,parent,controller):
tk.Frame.__init__(self,parent)
label1=tk.Label(self,width=50,text="Label 3",bg="#362458",fg="#FFFFFF")
label1.grid(row=2,pady=10,padx=10)
button1=tk.Button(self,text="Button 1",width=8,bg="#362458",fg="#FFFFFF",borderwidth=2, relief="solid",
command=lambda : [controller.show_frame(FinalPage),OnButtonClick(31)])
button1.grid(row=4,pady=10,padx=10)
button2=tk.Button(self,text="Button 2",width=8,bg="#362458",fg="#FFFFFF",borderwidth=2, relief="solid",
command=lambda : [controller.show_frame(FinalPage),OnButtonClick(32)])
button2.grid(row=6,pady=10,padx=10
class FinalPage(tk.Frame):
def __init__(self,parent,controller):
tk.Frame.__init__(self,parent)
button1=tk.Button(self,text="Click here to go to the start page",bg="#00BF89",fg="white",
command=lambda : controller.show_frame(StartPage))
button1.pack()
app=SeaofBTCapp()
app.mainloop()