I've been following Sentdex's playlist "GUI's with Tkinter (Intermediate)" and I can't figure out how to give information to a page. This is what I have so far
class Project(tk.Tk):
def init(self, *args, **kwargs):
tk.Tk.init(self, *args, *kwargs)
tk.Tk.wm_title(self, "Project")
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 (HomePage,PageOne, PageTwo):
frame = F(container, self)
self.frames[F] = frame
frame.grid(row=0, column=0, sticky="nsew")
self.show_frame(HomePage)
def show_frame(self, cont):
frame = self.frames[cont]
frame.tkraise()
class PageTwo:
def __init__(self,parent,controller,name):
tk.Frame.__init__(self,parent)
self.name=name
label = tk.Label(self, text=self.name, font=LARGE_FONT)
label.pack(pady=10, padx=10)
button = ttk.Button(self, text="Back to Team Page", command=lambda: controller.show_frame(HomePage))
button.pack()
The PageTwo class has needs to get name on it, but I keep getting a KeyError
frame = self.frames[cont]
KeyError: <__main__.Page2 object .!frame.!page2>
What can I do to fix this ?