123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- 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.h = 400
- self.w = 500
- self.faktor = [(0.125),(0.625), (0.25)]
- #self.resizable(height=False, width= False)
- self.geometry('{}x{}'.format(self.w,self.h))
-
- self.createTopFrame()
- self.createMainFrame()
- self.createBottomFrame()
-
- self.bind("<Configure>", self.adjustSize)
- 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)
- self.frames[f].adjustSize(height=(self.h*self.faktor[1]), width=self.w/2)
-
-
- def onClosing(self):
- print("closing")
- self.destroy()
-
-
- def createTopFrame(self):
- self.topFrame = Frame(self, bg="blue", height=50, width=500) #, padx=460, pady=10)
- self.toplabel = Label(self.topFrame, text="taktilles Buchstabieren")
-
- self.topFrame.columnconfigure(0, weight=1) # Set weight to row and
- self.topFrame.rowconfigure(0, weight=1) # column where the widget is
-
- self.topFrame.grid(column=0, row=0)
- self.topFrame.grid_propagate(0)
- self.topFrame.pack_propagate(0)
- self.toplabel.grid()
-
- 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)
-
- 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 = {}
- for F in (StartPage, WorkingPage):
- page_name = F.__name__
- frame = F(parent=self.container, controller=self.controller)
- self.frames[page_name] = frame
- frame.grid(row=0, column=0, sticky="nsew")
-
- self.changeFrame("StartPage")
-
- def createBottomFrame(self):
- self.bottomFrame = Frame(self, bg="green", height=100, width=500)
- self.bottomlabel = Label(self.bottomFrame, text="Hier stehen Infos\nGanz viele", justify='left')
-
- #self.bottomFrame.columnconfigure(0, weight=1) # Set weight to row and
- #self.bottomFrame.rowconfigure(0, weight=1) # column where the widget is
-
- self.bottomFrame.grid(column=0, row=2)
- self.bottomFrame.pack_propagate(0)
- self.bottomFrame.grid_propagate(0)
-
- self.bottomlabel.grid(padx=5,pady=5)
-
- def setInfoText(self, text):
- self.bottomlabel['text'] = text
-
- def setTitleText(self,text):
- self.toplabel['text'] = text
- 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
-
- self.leftFrame = Frame(self, bg="cyan", height=250, width=250)
- self.rightFrame = Frame(self, bg="blue", height=250, width=250)
-
- self.leftFrame.columnconfigure(0, weight=1) # Set weight to row and
- self.leftFrame.rowconfigure(0, weight=1) # column where the widget is
- self.leftFrame.grid_propagate(0)
- self.leftFrame.pack_propagate(0)
-
- self.rightFrame.columnconfigure(0, weight=1) # Set weight to row and
- self.rightFrame.rowconfigure(0, weight=1) # column where the widget is
- self.rightFrame.grid_propagate(0)
- self.rightFrame.pack_propagate(0)
-
- self.leftFrame.grid(column=0, row=0)
- self.rightFrame.grid(column=1, row=0)
-
- testBtn = Button(self.leftFrame, text="test", command=lambda: self.controller.actionPerformed("test"), height=6, width = 10)
- testBtn.grid()
-
- freeSpellingBtn = Button(self.rightFrame, text="freeSpelling", command=lambda: self.controller.actionPerformed("freeSpelling"), height=6, width = 10)
- freeSpellingBtn.grid()
-
- def adjustSize(self, height, width):
- self.leftFrame.configure(height=height, width= width)
- self.rightFrame.configure(height=height, width= width)
-
- class WorkingPage(Frame):
- def __init__(self, parent, controller):
- Frame.__init__(self, parent)
- self.controller = controller
-
- self.columnconfigure(0, weight=1) # Set weight to row and
- self.rowconfigure(0, weight=1) # column where the widget is
-
- stopBtn = Button(self, text="stop", command=lambda: self.controller.actionPerformed("stop"), height=6, width = 10)
- stopBtn.grid()
-
- def adjustSize(self, height, width):
- pass
|