try: from Tkinter import * except ImportError: from tkinter import * from UIController import * class View(Tk): def __init__(self, c, *args, **kwargs): Tk.__init__(self, *args, **kwargs) self.controller = c self.title("Taktiles Spelling") #self.resizable(height=False, width= False) self.geometry('500x400') #self.configure(bg="blue") self.createTopFrame() self.createMainFrame() self.createBottomFrame() self.protocol("WM_DELETE_WINDOW", self.onClosing) def createTopFrame(self): self.topFrame = Frame(self, bg="blue", height=50, width=500) #, padx=460, pady=10) l = Label(self.topFrame, text="taktilles Buchstabieren") self.topFrame.grid(column=0, row=0) self.topFrame.grid_propagate(0) self.topFrame.pack_propagate(0) l.pack() def createMainFrame(self): self.mainFrame = Frame(self, bg="red", height=250, width=500) self.mainFrame.grid(column=0, row=1) self.mainFrame.pack_propagate(0) container = Frame(self.mainFrame, bg="cyan", height=250, width=500) container.pack(side="top", fill="both", expand = True) container.pack_propagate(0) container.grid_propagate(0) self.frames = {} for F in (StartPage, WorkingPage): page_name = F.__name__ frame = F(parent=container, controller=self) self.frames[page_name] = frame # put all of the pages in the same location; # the one on the top of the stacking order # will be the one that is visible. frame.grid(row=0, column=0, sticky="nsew") self.changeFrame("StartPage") def changeFrame(self, pageName): frame = self.frames[pageName] frame.tkraise() #testBtn = Button(self.mainFrame, text="test", command=lambda: self.controller.actionPerformed("test"), height=6, width = 10) #testBtn.grid(row=0, column=0) #stopBtn = Button(self.mainFrame, text="stop", command=lambda: self.controller.actionPerformed("stop"), height=6, width = 10) #stopBtn.grid(row=0, column=1) def createBottomFrame(self): self.bottomFrame = Frame(self, bg="green", height=250, width=500) self.bottomFrame.grid(column=0, row=2) self.bottomFrame.pack_propagate(0) label = Label(self.bottomFrame, text="Hier stehen Infos") label.pack() def onClosing(self): print("closing") self.destroy() class StartPage(Frame): def __init__(self, parent, controller): Frame.__init__(self, parent, height=250, width=500, bg="red") self.grid_propagate(0) self.pack_propagate(0) self.controller = controller label = Label(self, text="This is the start page") label.pack(side="top", fill="x", pady=10) button1 = Button(self, text="Go to Page One", command=lambda: controller.changeFrame("WorkingPage")) button2 = Button(self, text="Go to Page Two", command=lambda: controller.changeFrame("WorkingPage")) button1.pack() button2.pack() class WorkingPage(Frame): def __init__(self, parent, controller): Frame.__init__(self, parent) self.controller = controller label = Label(self, text="This is page 1") label.pack(side="top", fill="x", pady=10) button = Button(self, text="Go to the start page", command=lambda: controller.changeFrame("StartPage")) button.pack()