Browse Source

UI Verbesserung

windowsdev
weberni69795 3 years ago
parent
commit
34d78660c3

+ 38
- 6
Masterarbeit/UIController.py View File

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 = {
"filterClassic": self.filterClassic "filterClassic": self.filterClassic
} }


self.pages = {
self.pagesTaktil = {
"stop": "StartPage", "stop": "StartPage",
"copySpelling": "WorkingPage",
"freeSpelling": "WorkingPage",
"test": "WorkingPage"
"copySpelling": "WorkingPageTaktil",
"freeSpelling": "WorkingPageTaktil",
"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):
def changeScreen(self, pageName): def changeScreen(self, pageName):
self.view.changeFrame(pageName=pageName) self.view.changeFrame(pageName=pageName)


def getModi(self):
return self.modi






+ 85
- 41
Masterarbeit/UIViewTKinter.py View File

except ImportError: except ImportError:
from tkinter import * from tkinter import *


from tkinter import font
from UIController import * from UIController import *




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.h = 800
self.w = 1000
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()
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):
def createTopFrame(self): 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 = Frame(self, bg=self.layout["backgroundBar"], height=50, width=500) #, padx=460, pady=10)
#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.rowconfigure(0, weight=1) # column where the widget is
#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(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.bottomlabel = Label(self.bottomFrame, text="Hier stehen Infos\nGanz viele", justify='left')
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', 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
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):
Frame.__init__(self, parent, height=250, width=500, bg="red")
def __init__(self, parent, controller, layout):
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.rightFrame = Frame(self, bg="blue", height=250, width=250)
self.container = Frame(self, bg=self.layout["background"], height=250, width=500)
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.leftFrame.rowconfigure(0, weight=1) # column where the widget is
self.leftFrame.grid_propagate(0)
self.leftFrame.pack_propagate(0)
self.container.columnconfigure(0, weight=1) # Set weight to row and
self.container.rowconfigure(0, weight=1) # column where the widget is
self.container.grid_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.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)
self.container.pack()
self.btnFrame.grid()
#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()
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"])
testBtn.grid(row=0,column=0, padx=25,pady=25)


freeSpellingBtn = Button(self.rightFrame, text="freeSpelling", command=lambda: self.controller.actionPerformed("freeSpelling"), height=6, width = 10)
freeSpellingBtn.grid()
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.rightFrame.configure(height=height, width= width)
self.container.configure(height=height, width= width)
self.btnFrame.configure(height=(height*4)/5, width= width/2)

class WorkingPageTaktil(Frame):
def __init__(self, parent, controller, layout):
self.layout = layout


class WorkingPage(Frame):
def __init__(self, parent, controller):
Frame.__init__(self, parent)
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

BIN
Masterarbeit/__pycache__/UIController.cpython-39.pyc View File


BIN
Masterarbeit/__pycache__/UIModell.cpython-39.pyc View File


BIN
Masterarbeit/__pycache__/UIViewPySide.cpython-39.pyc View File


BIN
Masterarbeit/__pycache__/UIViewTKinter.cpython-39.pyc View File


Loading…
Cancel
Save