|
|
|
|
|
|
|
|
|
|
|
|
|
|
from UIController import * |
|
|
from UIController import * |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class View(Tk): |
|
|
class View(Tk): |
|
|
def __init__(self, c, *args, **kwargs): |
|
|
def __init__(self, c, *args, **kwargs): |
|
|
Tk.__init__(self, *args, **kwargs) |
|
|
Tk.__init__(self, *args, **kwargs) |
|
|
self.controller = c |
|
|
self.controller = c |
|
|
self.title("Taktiles Spelling") |
|
|
self.title("Taktiles Spelling") |
|
|
|
|
|
self.h = 400 |
|
|
|
|
|
self.w = 500 |
|
|
|
|
|
self.faktor = [(0.125),(0.625), (0.25)] |
|
|
#self.resizable(height=False, width= False) |
|
|
#self.resizable(height=False, width= False) |
|
|
self.geometry('500x400') |
|
|
|
|
|
#self.configure(bg="blue") |
|
|
|
|
|
|
|
|
self.geometry('{}x{}'.format(self.w,self.h)) |
|
|
|
|
|
|
|
|
self.createTopFrame() |
|
|
self.createTopFrame() |
|
|
self.createMainFrame() |
|
|
self.createMainFrame() |
|
|
self.createBottomFrame() |
|
|
self.createBottomFrame() |
|
|
|
|
|
|
|
|
|
|
|
self.bind("<Configure>", self.adjustSize) |
|
|
self.protocol("WM_DELETE_WINDOW", self.onClosing) |
|
|
self.protocol("WM_DELETE_WINDOW", self.onClosing) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def changeFrame(self, pageName): |
|
|
|
|
|
frame = self.frames[pageName] |
|
|
|
|
|
frame.tkraise() |
|
|
|
|
|
|
|
|
|
|
|
def adjustSize(self, event): |
|
|
|
|
|
if(str(event.widget) =="."): |
|
|
|
|
|
self.h = event.height |
|
|
|
|
|
self.w = event.width |
|
|
|
|
|
self.topFrame.configure(height=(self.h*self.faktor[0]), width=self.w) |
|
|
|
|
|
self.mainFrame.configure(height=(self.h*self.faktor[1]), width=self.w) |
|
|
|
|
|
self.bottomFrame.configure(height=(self.h*self.faktor[2]), width=self.w) |
|
|
|
|
|
self.container.configure(height=(self.h*self.faktor[1]), width=self.w) |
|
|
|
|
|
for f in self.frames: |
|
|
|
|
|
self.frames[f].configure(height=(self.h*self.faktor[1]), width=self.w) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def onClosing(self): |
|
|
|
|
|
print("closing") |
|
|
|
|
|
self.destroy() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def createTopFrame(self): |
|
|
def createTopFrame(self): |
|
|
|
|
|
|
|
|
self.mainFrame.grid(column=0, row=1) |
|
|
self.mainFrame.grid(column=0, row=1) |
|
|
self.mainFrame.pack_propagate(0) |
|
|
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.container = Frame(self.mainFrame, bg="cyan", height=250, width=500) |
|
|
|
|
|
self.container.pack(side="top", fill="both", expand = True) |
|
|
|
|
|
self.container.pack_propagate(0) |
|
|
|
|
|
self.container.grid_propagate(0) |
|
|
|
|
|
|
|
|
self.frames = {} |
|
|
self.frames = {} |
|
|
for F in (StartPage, WorkingPage): |
|
|
for F in (StartPage, WorkingPage): |
|
|
page_name = F.__name__ |
|
|
page_name = F.__name__ |
|
|
frame = F(parent=container, controller=self) |
|
|
|
|
|
|
|
|
frame = F(parent=self.container, controller=self.controller) |
|
|
self.frames[page_name] = frame |
|
|
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") |
|
|
frame.grid(row=0, column=0, sticky="nsew") |
|
|
|
|
|
|
|
|
self.changeFrame("StartPage") |
|
|
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): |
|
|
def createBottomFrame(self): |
|
|
self.bottomFrame = Frame(self, bg="green", height=250, width=500) |
|
|
|
|
|
|
|
|
self.bottomFrame = Frame(self, bg="green", height=100, width=500) |
|
|
self.bottomFrame.grid(column=0, row=2) |
|
|
self.bottomFrame.grid(column=0, row=2) |
|
|
self.bottomFrame.pack_propagate(0) |
|
|
self.bottomFrame.pack_propagate(0) |
|
|
|
|
|
|
|
|
label = Label(self.bottomFrame, text="Hier stehen Infos") |
|
|
label = Label(self.bottomFrame, text="Hier stehen Infos") |
|
|
label.pack() |
|
|
|
|
|
|
|
|
|
|
|
def onClosing(self): |
|
|
|
|
|
print("closing") |
|
|
|
|
|
self.destroy() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
label.pack() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class StartPage(Frame): |
|
|
class StartPage(Frame): |
|
|
|
|
|
|
|
|
self.grid_propagate(0) |
|
|
self.grid_propagate(0) |
|
|
self.pack_propagate(0) |
|
|
self.pack_propagate(0) |
|
|
self.controller = controller |
|
|
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() |
|
|
|
|
|
|
|
|
testBtn = Button(self, text="test", command=lambda: self.controller.actionPerformed("test"), height=6, width = 10) |
|
|
|
|
|
testBtn.grid(row=0, column=0) |
|
|
|
|
|
|
|
|
|
|
|
freeSpellingBtn = Button(self, text="freeSpelling", command=lambda: self.controller.actionPerformed("freeSpelling"), height=6, width = 10) |
|
|
|
|
|
freeSpellingBtn.grid(row=0, column=1) |
|
|
|
|
|
|
|
|
class WorkingPage(Frame): |
|
|
class WorkingPage(Frame): |
|
|
def __init__(self, parent, controller): |
|
|
def __init__(self, parent, controller): |
|
|
Frame.__init__(self, parent) |
|
|
Frame.__init__(self, parent) |
|
|
self.controller = controller |
|
|
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() |
|
|
|
|
|
|
|
|
stopBtn = Button(self, text="stop", command=lambda: self.controller.actionPerformed("stop"), height=6, width = 10) |
|
|
|
|
|
stopBtn.pack() |