UI Verbesserung

This commit is contained in:
weberni69795 2021-10-25 07:51:18 +02:00
parent 249fa25357
commit 34d78660c3
6 changed files with 123 additions and 47 deletions

View File

@ -8,12 +8,15 @@ class Controller():
def __init__(self): def __init__(self):
self.view = viewTkinter.View(self) self.view = viewTkinter.View(self)
self.modi = "taktilesBCI"
self.commands = { self.commands = {
"copySpelling": self.commandoCopySpelling, "copySpelling": self.commandoCopySpelling,
"stop": self.commandStop, "stop": self.commandStop,
"freeSpelling": self.commandFreeSpelling, "freeSpelling": self.commandFreeSpelling,
"test": self.test "test": self.test,
"wechsel": self.wechsel,
"speicherort": self.speicherort
} }
self.nexts = { self.nexts = {
@ -21,22 +24,48 @@ class Controller():
"filterClassic": self.filterClassic "filterClassic": self.filterClassic
} }
self.pages = { self.pagesTaktil = {
"stop": "StartPage", "stop": "StartPage",
"copySpelling": "WorkingPage", "copySpelling": "WorkingPageTaktil",
"freeSpelling": "WorkingPage", "freeSpelling": "WorkingPageTaktil",
"test": "WorkingPage" "test": "WorkingPageTaktil"
}
self.pagesVisuell = {
"stop": "StartPage",
"copySpelling": "WorkingPageVisuell",
"freeSpelling": "WorkingPageVisuell",
"test": "WorkingPageVisuell"
} }
self.view.mainloop() self.view.mainloop()
def actionPerformed(self, action): def actionPerformed(self, action):
self.view.changeFrame(self.pages.get(action)) self.changePage(action)
func = self.commands.get(action) func = self.commands.get(action)
if(func is not None): if(func is not None):
func() func()
else: else:
print("Kommado existiert nicht") print("Kommado existiert nicht")
def changePage(self,action):
if(self.modi == "taktilesBCI"):
page = self.pagesTaktil.get(action)
elif(self.modi == "visuellesBCI"):
page = self.pagesVisuell.get(action)
if(page is not None):
self.view.changeFrame(self.pages.get(action))
def wechsel(self):
if(self.modi == "taktilesBCI"):
self.view.setChangeBtnText("Wechsel zu taktilen BCI")
self.view.setTitleText("visuelles BCI")
self.modi = "visuellesBCI"
elif(self.modi == "visuellesBCI"):
self.setTitle("taktiles BCI")
self.view.setChangeBtnText("Wechsel zu visuellen BCI")
self.modi = "taktilesBCI"
def speicherort(self):
pass
def test(self): def test(self):
@ -95,5 +124,8 @@ class Controller():
def changeScreen(self, pageName): def changeScreen(self, pageName):
self.view.changeFrame(pageName=pageName) self.view.changeFrame(pageName=pageName)
def getModi(self):
return self.modi

View File

@ -3,6 +3,7 @@ try:
except ImportError: except ImportError:
from tkinter import * from tkinter import *
from tkinter import font
from UIController import * from UIController import *
@ -12,11 +13,19 @@ class View(Tk):
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.h = 800
self.w = 500 self.w = 1000
self.faktor = [(0.125),(0.625), (0.25)]
#self.resizable(height=False, width= False)
self.geometry('{}x{}'.format(self.w,self.h)) self.geometry('{}x{}'.format(self.w,self.h))
self.faktor = [(0.0675),(0.6825), (0.25)]
#self.resizable(height=False, width= False)
self.layout = {
"background": "#00001E",
"backgroundBtn": "#1C86EE",
"fontColor": "#FFFFFF",
"backgroundBar": "#00002E",
"font": ('times', 25, 'bold'),
"fontSmall": ('times', 10, 'bold')
}
self.createTopFrame() self.createTopFrame()
self.createMainFrame() self.createMainFrame()
@ -40,7 +49,7 @@ class View(Tk):
self.container.configure(height=(self.h*self.faktor[1]), width=self.w) self.container.configure(height=(self.h*self.faktor[1]), width=self.w)
for f in self.frames: for f in self.frames:
self.frames[f].configure(height=(self.h*self.faktor[1]), width=self.w) 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) self.frames[f].adjustSize(height=(self.h*self.faktor[1]), width=self.w)
def onClosing(self): def onClosing(self):
@ -49,40 +58,44 @@ class View(Tk):
def createTopFrame(self): def createTopFrame(self):
self.topFrame = Frame(self, bg="blue", height=50, width=500) #, padx=460, pady=10) self.topFrame = Frame(self, bg=self.layout["backgroundBar"], height=50, width=500) #, padx=460, pady=10)
self.toplabel = Label(self.topFrame, text="taktilles Buchstabieren") #self.toplabel = Label(self.topFrame, text="taktilles Buchstabieren")
self.changeBtn = Button(self.topFrame, text="Wechsel zu visuellen BCI", command=lambda: self.controller.actionPerformed("wechsel"), height=3, width = 25, font=self.layout["fontSmall"], bg=self.layout["backgroundBtn"], fg=self.layout["fontColor"])
self.saveBtn = Button(self.topFrame, text="Änderung des Speicherorts", command=lambda: self.controller.actionPerformed("speicherort"), height=3, width = 25, font=self.layout["fontSmall"], bg=self.layout["backgroundBtn"], fg=self.layout["fontColor"])
self.topFrame.columnconfigure(0, weight=1) # Set weight to row and #self.topFrame.columnconfigure(0, weight=1) # Set weight to row and
self.topFrame.rowconfigure(0, weight=1) # column where the widget is #self.topFrame.rowconfigure(0, weight=1) # column where the widget is
self.topFrame.grid(column=0, row=0) self.topFrame.grid(column=0, row=0)
self.topFrame.grid_propagate(0) self.topFrame.grid_propagate(0)
self.topFrame.pack_propagate(0) self.topFrame.pack_propagate(0)
self.toplabel.grid() #self.toplabel.grid()
self.changeBtn.grid(column=0, row=0, padx=10,pady=5)
self.saveBtn.grid(column=1, row=0, padx=10, pady=5)
def createMainFrame(self): def createMainFrame(self):
self.mainFrame = Frame(self, bg="red", height=250, width=500) self.mainFrame = Frame(self, bg=self.layout["background"], height=250, width=500)
self.mainFrame.grid(column=0, row=1) self.mainFrame.grid(column=0, row=1)
self.mainFrame.pack_propagate(0) self.mainFrame.pack_propagate(0)
self.container = Frame(self.mainFrame, bg="cyan", height=250, width=500) self.container = Frame(self.mainFrame, bg=self.layout["background"], height=250, width=500)
self.container.pack(side="top", fill="both", expand = True) self.container.pack(side="top", fill="both", expand = True)
self.container.pack_propagate(0) self.container.pack_propagate(0)
self.container.grid_propagate(0) self.container.grid_propagate(0)
self.frames = {} self.frames = {}
for F in (StartPage, WorkingPage): for F in (StartPage, WorkingPageTaktil, WorkingPageVisuell):
page_name = F.__name__ page_name = F.__name__
frame = F(parent=self.container, controller=self.controller) frame = F(parent=self.container, controller=self.controller, layout=self.layout)
self.frames[page_name] = frame self.frames[page_name] = frame
frame.grid(row=0, column=0, sticky="nsew") frame.grid(row=0, column=0, sticky="nsew")
self.changeFrame("StartPage") self.changeFrame("StartPage")
def createBottomFrame(self): def createBottomFrame(self):
self.bottomFrame = Frame(self, bg="green", height=100, width=500) self.bottomFrame = Frame(self, bg=self.layout["backgroundBar"], height=100, width=500)
self.bottomlabel = Label(self.bottomFrame, text="Hier stehen Infos\nGanz viele", justify='left') self.bottomlabel = Label(self.bottomFrame, text="Hier stehen Infos\nGanz viele", justify='left', font=self.layout["font"], bg=self.layout["backgroundBar"], fg=self.layout["fontColor"])
#self.bottomFrame.columnconfigure(0, weight=1) # Set weight to row and #self.bottomFrame.columnconfigure(0, weight=1) # Set weight to row and
#self.bottomFrame.rowconfigure(0, weight=1) # column where the widget is #self.bottomFrame.rowconfigure(0, weight=1) # column where the widget is
@ -97,50 +110,81 @@ class View(Tk):
self.bottomlabel['text'] = text self.bottomlabel['text'] = text
def setTitleText(self,text): def setTitleText(self,text):
self.toplabel['text'] = text self.title(text)
def setChangeBtnText(self,text):
self.changeBtn["text"] = text
class StartPage(Frame): class StartPage(Frame):
def __init__(self, parent, controller): def __init__(self, parent, controller, layout):
Frame.__init__(self, parent, height=250, width=500, bg="red") self.layout = layout
Frame.__init__(self, parent, height=250, width=500, bg=self.layout["background"])
self.grid_propagate(0) self.grid_propagate(0)
self.pack_propagate(0) self.pack_propagate(0)
self.controller = controller self.controller = controller
self.leftFrame = Frame(self, bg="cyan", height=250, width=250) self.container = Frame(self, bg=self.layout["background"], height=250, width=500)
self.rightFrame = Frame(self, bg="blue", height=250, width=250) self.btnFrame = Frame(self.container, bg=self.layout["background"], height=250, width=250)
#self.rightFrame = Frame(self, bg=self.layout["background"], height=250, width=250)
self.leftFrame.columnconfigure(0, weight=1) # Set weight to row and self.container.columnconfigure(0, weight=1) # Set weight to row and
self.leftFrame.rowconfigure(0, weight=1) # column where the widget is self.container.rowconfigure(0, weight=1) # column where the widget is
self.leftFrame.grid_propagate(0) self.container.grid_propagate(0)
self.leftFrame.pack_propagate(0) self.container.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.columnconfigure(0, weight=1) # Set weight to row and
self.rightFrame.grid(column=1, row=0) #self.rightFrame.rowconfigure(0, weight=1) # column where the widget is
#self.rightFrame.grid_propagate(0)
#self.rightFrame.pack_propagate(0)
testBtn = Button(self.leftFrame, text="test", command=lambda: self.controller.actionPerformed("test"), height=6, width = 10) self.container.pack()
testBtn.grid() self.btnFrame.grid()
#self.rightFrame.grid(column=1, row=0)
freeSpellingBtn = Button(self.rightFrame, text="freeSpelling", command=lambda: self.controller.actionPerformed("freeSpelling"), height=6, width = 10) testBtn = Button(self.btnFrame, text="copySpelling", command=lambda: self.controller.actionPerformed("test"), height=6, width = 20, font=self.layout["font"], bg=self.layout["backgroundBtn"], fg=self.layout["fontColor"])
freeSpellingBtn.grid() testBtn.grid(row=0,column=0, padx=25,pady=25)
freeSpellingBtn = Button(self.btnFrame, text="freeSpelling", command=lambda: self.controller.actionPerformed("freeSpelling"), height=6, width = 20, font=self.layout["font"], bg=self.layout["backgroundBtn"], fg=self.layout["fontColor"])
freeSpellingBtn.grid(row=0, column=1, padx=25,pady=25)
def adjustSize(self, height, width): def adjustSize(self, height, width):
self.leftFrame.configure(height=height, width= width) self.container.configure(height=height, width= width)
self.rightFrame.configure(height=height, width= width) self.btnFrame.configure(height=(height*4)/5, width= width/2)
class WorkingPage(Frame): class WorkingPageTaktil(Frame):
def __init__(self, parent, controller): def __init__(self, parent, controller, layout):
Frame.__init__(self, parent) self.layout = layout
Frame.__init__(self, parent, height=250, width=500, bg=self.layout["background"])
self.controller = controller self.controller = controller
self.columnconfigure(0, weight=1) # Set weight to row and self.columnconfigure(0, weight=1) # Set weight to row and
self.rowconfigure(0, weight=1) # column where the widget is 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 = Button(self, text="stop", command=lambda: self.controller.actionPerformed("stop"), height=4, width = 15, font=self.layout["font"], bg=self.layout["backgroundBtn"], fg=self.layout["fontColor"])
stopBtn.grid() stopBtn.grid()
def adjustSize(self, height, width): def adjustSize(self, height, width):
pass pass
class WorkingPageVisuell(Frame):
def __init__(self, parent, controller, layout):
self.layout = layout
Frame.__init__(self, parent, height=250, width=500, bg=self.layout["background"])
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=4, width = 15, font=self.layout["font"], bg=self.layout["backgroundBtn"], fg=self.layout["fontColor"])
stopBtn.grid()
def adjustSize(self, height, width):
pass

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.