Browse Source

Fix directory paths

master
Igor Beloschapkin 4 years ago
parent
commit
e0dead5534
3 changed files with 22 additions and 23 deletions
  1. 3
    1
      README.md
  2. 18
    21
      app.py
  3. 1
    1
      config.ini

+ 3
- 1
README.md View File

PythonBCIgui PythonBCIgui
============
============

Die PythonBCIgui ist eine grafische Oberfläche zum Aufrufen einzelner Programmteile, die für ein BCI benötigt werden.

+ 18
- 21
app.py View File

import tkinter.filedialog import tkinter.filedialog
import subprocess import subprocess
import configparser import configparser
import os


# own code: # own code:
# from questionnaire import quest # from questionnaire import quest
class PythonBCIgui: class PythonBCIgui:


def __init__(self, master): 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 # Einstellung der Button Größe
textH = 4 textH = 4
textHsmall = 2 textHsmall = 2
textW = 20 textW = 20

def makeBtn(self, text, bg, command): def makeBtn(self, text, bg, command):
self.button = tkinter.Button(frame, text=text, bg=bg, command=command) self.button = tkinter.Button(frame, text=text, bg=bg, command=command)
self.button.config( height = textH, width = textW ) self.button.config( height = textH, width = textW )
self.BvisCopy = makeBtn(self, "Freies Buchstabieren", "lightblue", self.btn_visCopy) self.BvisCopy = makeBtn(self, "Freies Buchstabieren", "lightblue", self.btn_visCopy)


self.BtacSimul = makeBtn(self, "Rollstuhlsimulator", "lightyellow", self.btn_tacSimul) self.BtacSimul = makeBtn(self, "Rollstuhlsimulator", "lightyellow", self.btn_tacSimul)
# self.Bquest = makeBtnSmall(self, "Fragebogen", "green", self.btn_quest, TOP) # self.Bquest = makeBtnSmall(self, "Fragebogen", "green", self.btn_quest, TOP)


frame.rowconfigure((0,1), weight=1) # make buttons stretch when frame.rowconfigure((0,1), weight=1) # make buttons stretch when
# q.qSubjControl() # q.qSubjControl()
# q.qCtrlChange() # q.qCtrlChange()
# q.save() # q.save()
def pack_layout(self): def pack_layout(self):
# This Function packs all the Buttons into the Layout # This Function packs all the Buttons into the Layout
if config['SETTINGS']['paradigm'] == 'Tactile': if config['SETTINGS']['paradigm'] == 'Tactile':
self.BtacSimul.pack() self.BtacSimul.pack()
elif config['SETTINGS']['paradigm'] == 'Visual': elif config['SETTINGS']['paradigm'] == 'Visual':
self.BvisCopy.pack() self.BvisCopy.pack()
def unpack_layout(self): def unpack_layout(self):
# This Function removes all the Buttons from the Layout # This Function removes all the Buttons from the Layout
# Add ALL your Buttons here # Add ALL your Buttons here
print('Beenden') print('Beenden')
window.destroy() 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 = configparser.ConfigParser()
config.read('config.ini')
configPath = pathOrigin + '/config.ini'
config.read(configPath)



def setVisual(): def setVisual():
config['SETTINGS']['paradigm'] = 'Visual' config['SETTINGS']['paradigm'] = 'Visual'
config.write(open('config.ini','w'))
config.write(open(configPath,'w'))
app.Lparadigm.config(text = config['SETTINGS']['paradigm'] + ' BCI') app.Lparadigm.config(text = config['SETTINGS']['paradigm'] + ' BCI')
app.unpack_layout() app.unpack_layout()
app.pack_layout() app.pack_layout()


def setTactile(): def setTactile():
config['SETTINGS']['paradigm'] = 'Tactile' config['SETTINGS']['paradigm'] = 'Tactile'
config.write(open('config.ini','w'))
config.write(open(configPath,'w'))
app.Lparadigm.config(text = config['SETTINGS']['paradigm'] + ' BCI') app.Lparadigm.config(text = config['SETTINGS']['paradigm'] + ' BCI')
app.unpack_layout() app.unpack_layout()
app.pack_layout() app.pack_layout()
pass pass
else: else:
config['PATH']['bci2000'] = tmpPath config['PATH']['bci2000'] = tmpPath
config.write(open('config.ini','w'))
config.write(open(configPath,'w'))


def setPathTactileBCIFilter(): def setPathTactileBCIFilter():
tkinter.messagebox.showinfo('Konfiguration', 'Bitte wählen Sie nun den Ordner aus, in dem sich die TactileBCIfilter.exe befindet.') tkinter.messagebox.showinfo('Konfiguration', 'Bitte wählen Sie nun den Ordner aus, in dem sich die TactileBCIfilter.exe befindet.')
pass pass
else: else:
config['PATH']['tactilebcifilter'] = tmpPath config['PATH']['tactilebcifilter'] = tmpPath
config.write(open('config.ini','w'))
config.write(open(configPath,'w'))


def setConfigDefault(): 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']['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['PATH']['bci2000'] = r'C:/BCI2000/BCI2000 v3.6.beta.R5570/BCI2000.x64'
config['SETTINGS']['paradigm'] = r'Visual' config['SETTINGS']['paradigm'] = r'Visual'
config['SETTINGS']['hardware'] = r'gUSBamp' 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.Lparadigm.config(text = config['SETTINGS']['paradigm'] + ' BCI')
app.unpack_layout() app.unpack_layout()
app.pack_layout() app.pack_layout()
root.mainloop() root.mainloop()
#root.destroy() # optional; #root.destroy() # optional;


# TODO Remove prints before deployment
# TODO Remove prints before deployment

+ 1
- 1
config.ini View File

[SETTINGS] [SETTINGS]
paradigm = Tactile
paradigm = Visual
hardware = gUSBamp hardware = gUSBamp


[PATH] [PATH]

Loading…
Cancel
Save