update
This commit is contained in:
parent
7fa199db64
commit
58f6c81562
@ -1,6 +1,7 @@
|
||||
from UIModell import *
|
||||
import UIViewTKinter as viewTkinter
|
||||
import UIViewPySide as viewPySide
|
||||
from threading import Thread
|
||||
|
||||
|
||||
class Controller():
|
||||
@ -16,9 +17,18 @@ class Controller():
|
||||
"test": self.test
|
||||
}
|
||||
|
||||
self.pages = {
|
||||
"stop": "StartPage",
|
||||
"copySpelling": "WorkingPage",
|
||||
"freeSpelling": "WorkingPage",
|
||||
"test": "WorkingPage"
|
||||
}
|
||||
|
||||
|
||||
self.view.mainloop()
|
||||
|
||||
def actionPerformed(self, action):
|
||||
self.view.changeFrame(self.pages.get(action))
|
||||
func = self.commands.get(action)
|
||||
if(func is not None):
|
||||
func()
|
||||
@ -26,8 +36,11 @@ class Controller():
|
||||
print("Kommado existiert nicht")
|
||||
|
||||
|
||||
|
||||
def test(self):
|
||||
self.model.trainXDawn()
|
||||
self.thread = Thread(target=self.model.trainXDawn)
|
||||
self.thread.start()
|
||||
#self.model.trainXDawn()
|
||||
|
||||
def commandoCopySpelling(self):
|
||||
self.model.startCopySpelling()
|
||||
@ -39,5 +52,6 @@ class Controller():
|
||||
|
||||
def commandStop(self):
|
||||
self.model.killProzess()
|
||||
self.thread.join()
|
||||
|
||||
|
||||
|
Binary file not shown.
@ -97,3 +97,6 @@ class Modell():
|
||||
|
||||
|
||||
print("killed openvibe-designer")
|
||||
|
||||
|
||||
|
||||
|
@ -5,20 +5,46 @@ except ImportError:
|
||||
|
||||
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('500x400')
|
||||
#self.configure(bg="blue")
|
||||
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)
|
||||
|
||||
|
||||
def onClosing(self):
|
||||
print("closing")
|
||||
self.destroy()
|
||||
|
||||
|
||||
def createTopFrame(self):
|
||||
@ -36,47 +62,27 @@ class View(Tk):
|
||||
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.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=container, controller=self)
|
||||
frame = F(parent=self.container, controller=self.controller)
|
||||
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 = Frame(self, bg="green", height=100, 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()
|
||||
|
||||
label.pack()
|
||||
|
||||
|
||||
class StartPage(Frame):
|
||||
@ -85,22 +91,16 @@ class StartPage(Frame):
|
||||
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()
|
||||
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):
|
||||
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()
|
||||
stopBtn = Button(self, text="stop", command=lambda: self.controller.actionPerformed("stop"), height=6, width = 10)
|
||||
stopBtn.pack()
|
||||
|
Binary file not shown.
@ -1,84 +1,42 @@
|
||||
try:
|
||||
import tkinter as tk # python 3
|
||||
from tkinter import font as tkfont # python 3
|
||||
except ImportError:
|
||||
import Tkinter as tk # python 2
|
||||
import tkFont as tkfont # python 2
|
||||
from threading import Thread
|
||||
import time
|
||||
from itertools import count
|
||||
|
||||
class SampleApp(tk.Tk):
|
||||
class Modell(Thread):
|
||||
def __init__(self):
|
||||
Thread.__init__(self)
|
||||
self.running = True
|
||||
|
||||
def stop(self):
|
||||
self.running = False
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
tk.Tk.__init__(self, *args, **kwargs)
|
||||
def setFunktion(self, func, args=None, kwargs=None):
|
||||
self.func = func
|
||||
self.args = args or []
|
||||
self.kwargs = kwargs or {}
|
||||
|
||||
def run(self):
|
||||
t = Thread(target=self.func, args=self.args, kwargs=self.kwargs)
|
||||
t.setDaemon(True)
|
||||
t.start()
|
||||
|
||||
while self.running:
|
||||
time.sleep(0.1)
|
||||
|
||||
|
||||
self.title_font = tkfont.Font(family='Helvetica', size=18, weight="bold", slant="italic")
|
||||
|
||||
# the container is where we'll stack a bunch of frames
|
||||
# on top of each other, then the one we want visible
|
||||
# will be raised above the others
|
||||
container = tk.Frame(self)
|
||||
container.pack(side="top", fill="both", expand=True)
|
||||
container.grid_rowconfigure(0, weight=1)
|
||||
container.grid_columnconfigure(0, weight=1)
|
||||
|
||||
self.frames = {}
|
||||
for F in (StartPage, PageOne, PageTwo):
|
||||
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.show_frame("StartPage")
|
||||
|
||||
def show_frame(self, page_name):
|
||||
'''Show a frame for the given page name'''
|
||||
frame = self.frames[page_name]
|
||||
frame.tkraise()
|
||||
def worker(self):
|
||||
i= 0
|
||||
while True:
|
||||
i = i+1
|
||||
print(i)
|
||||
time.sleep(0.05)
|
||||
|
||||
c = Modell()
|
||||
c.setFunktion(c.worker)
|
||||
c.start()
|
||||
|
||||
|
||||
class StartPage(tk.Frame):
|
||||
t = time.time()
|
||||
time.sleep(3)
|
||||
|
||||
def __init__(self, parent, controller):
|
||||
tk.Frame.__init__(self, parent)
|
||||
self.controller = controller
|
||||
label = tk.Label(self, text="This is the start page", font=controller.title_font)
|
||||
label.pack(side="top", fill="x", pady=10)
|
||||
|
||||
button1 = tk.Button(self, text="Go to Page One",
|
||||
command=lambda: controller.show_frame("PageOne"))
|
||||
button2 = tk.Button(self, text="Go to Page Two",
|
||||
command=lambda: controller.show_frame("PageTwo"))
|
||||
button1.pack()
|
||||
button2.pack()
|
||||
|
||||
|
||||
class PageOne(tk.Frame):
|
||||
|
||||
def __init__(self, parent, controller):
|
||||
tk.Frame.__init__(self, parent)
|
||||
self.controller = controller
|
||||
label = tk.Label(self, text="This is page 1", font=controller.title_font)
|
||||
label.pack(side="top", fill="x", pady=10)
|
||||
button = tk.Button(self, text="Go to the start page",
|
||||
command=lambda: controller.show_frame("StartPage"))
|
||||
button.pack()
|
||||
|
||||
|
||||
class PageTwo(tk.Frame):
|
||||
|
||||
def __init__(self, parent, controller):
|
||||
tk.Frame.__init__(self, parent)
|
||||
self.controller = controller
|
||||
label = tk.Label(self, text="This is page 2", font=controller.title_font)
|
||||
label.pack(side="top", fill="x", pady=10)
|
||||
button = tk.Button(self, text="Go to the start page",
|
||||
command=lambda: controller.show_frame("StartPage"))
|
||||
button.pack()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = SampleApp()
|
||||
app.mainloop()
|
||||
c.stop()
|
||||
|
Loading…
x
Reference in New Issue
Block a user