diff --git a/README.md b/README.md index 466988c..3c6f785 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ PythonBCIgui -============ \ No newline at end of file +============ + +Die PythonBCIgui ist eine grafische Oberfläche zum Aufrufen einzelner Programmteile, die für ein BCI benötigt werden. diff --git a/app.py b/app.py index 9036877..65c054f 100644 --- a/app.py +++ b/app.py @@ -10,6 +10,7 @@ import tkinter.font import tkinter.filedialog import subprocess import configparser +import os # own code: # from questionnaire import quest @@ -21,20 +22,11 @@ __version__ = 0.3 class PythonBCIgui: def __init__(self, master): - #pathOrigin = os.path.dirname(os.path.realpath(__file__)) - #print(pathOrigin) - - # TODO current working directory auf root von dieser file setzen - - # global pathSave - # pathSave = "\\questions\\" + self.paradigmText - # pathSave = os.getcwd() + pathSave - # Einstellung der Button Größe textH = 4 textHsmall = 2 textW = 20 - + def makeBtn(self, text, bg, command): self.button = tkinter.Button(frame, text=text, bg=bg, command=command) self.button.config( height = textH, width = textW ) @@ -68,7 +60,7 @@ class PythonBCIgui: self.BvisCopy = makeBtn(self, "Freies Buchstabieren", "lightblue", self.btn_visCopy) self.BtacSimul = makeBtn(self, "Rollstuhlsimulator", "lightyellow", self.btn_tacSimul) - + # self.Bquest = makeBtnSmall(self, "Fragebogen", "green", self.btn_quest, TOP) frame.rowconfigure((0,1), weight=1) # make buttons stretch when @@ -139,7 +131,7 @@ class PythonBCIgui: # q.qSubjControl() # q.qCtrlChange() # q.save() - + def pack_layout(self): # This Function packs all the Buttons into the Layout if config['SETTINGS']['paradigm'] == 'Tactile': @@ -153,7 +145,7 @@ class PythonBCIgui: self.BtacSimul.pack() elif config['SETTINGS']['paradigm'] == 'Visual': self.BvisCopy.pack() - + def unpack_layout(self): # This Function removes all the Buttons from the Layout # Add ALL your Buttons here @@ -169,20 +161,24 @@ class PythonBCIgui: print('Beenden') window.destroy() - +# set paths +pathOrigin = os.path.dirname(os.path.realpath(__file__)) # set pathOrigin to directory of this file +os.chdir(pathOrigin) config = configparser.ConfigParser() -config.read('config.ini') +configPath = pathOrigin + '/config.ini' +config.read(configPath) + def setVisual(): config['SETTINGS']['paradigm'] = 'Visual' - config.write(open('config.ini','w')) + config.write(open(configPath,'w')) app.Lparadigm.config(text = config['SETTINGS']['paradigm'] + ' BCI') app.unpack_layout() app.pack_layout() def setTactile(): config['SETTINGS']['paradigm'] = 'Tactile' - config.write(open('config.ini','w')) + config.write(open(configPath,'w')) app.Lparadigm.config(text = config['SETTINGS']['paradigm'] + ' BCI') app.unpack_layout() app.pack_layout() @@ -197,7 +193,7 @@ def setPathBci2000(): pass else: config['PATH']['bci2000'] = tmpPath - config.write(open('config.ini','w')) + config.write(open(configPath,'w')) def setPathTactileBCIFilter(): tkinter.messagebox.showinfo('Konfiguration', 'Bitte wählen Sie nun den Ordner aus, in dem sich die TactileBCIfilter.exe befindet.') @@ -206,14 +202,15 @@ def setPathTactileBCIFilter(): pass else: config['PATH']['tactilebcifilter'] = tmpPath - config.write(open('config.ini','w')) + config.write(open(configPath,'w')) def setConfigDefault(): + # TODO Pfade von Wolfgang einbauen config['PATH']['tactilebcifilter'] = r'C:/Users/bci/Desktop/Qt Filter Program/build-TactileBCIFilter-Desktop_Qt_5_15_0_MinGW_32_bit-Release/release' config['PATH']['bci2000'] = r'C:/BCI2000/BCI2000 v3.6.beta.R5570/BCI2000.x64' config['SETTINGS']['paradigm'] = r'Visual' config['SETTINGS']['hardware'] = r'gUSBamp' - config.write(open('config.ini','w')) + config.write(open(configPath,'w')) app.Lparadigm.config(text = config['SETTINGS']['paradigm'] + ' BCI') app.unpack_layout() app.pack_layout() @@ -251,4 +248,4 @@ app = PythonBCIgui(root) root.mainloop() #root.destroy() # optional; -# TODO Remove prints before deployment \ No newline at end of file +# TODO Remove prints before deployment diff --git a/config.ini b/config.ini index ffda7af..5d2daa3 100644 --- a/config.ini +++ b/config.ini @@ -1,5 +1,5 @@ [SETTINGS] -paradigm = Tactile +paradigm = Visual hardware = gUSBamp [PATH]