Read Paths from config.ini

This commit is contained in:
bci 2020-09-04 15:27:03 +02:00
parent f78ba4434a
commit bd550e1cd0

75
app.py
View File

@ -15,26 +15,6 @@ import configparser
# TODO Eventuell updatefunktion über git pull mit einbauen! # TODO Eventuell updatefunktion über git pull mit einbauen!
##################################################
# Config Beginn
# Folgende Strings bitte an jeweiligen PC anpassen
# in folgendem Format: variable = r'C:\Pfad' ("r" vor Pfad nicht vergessen!!!)
# Hier findet man die Ordner batch, data, icons, parms, prog, tools
pathBci2000 = r'C:\BCI2000\BCI2000 v3.6.beta.R5570\BCI2000.x64'
# Hier findet man den TactileBCIFilter.exe
pathTactileBciFilter = r'C:\Users\bci\Desktop\Qt Filter Program\build-TactileBCIFilter-Desktop_Qt_5_15_0_MinGW_32_bit-Release\release'
# Hier findet man die P300Classifier.exe
pathP300Classifier = r'C:\Users\bci\Desktop\Igor\PythonBCIgui_v0.2\bin'
# TODO Config in txt file verlagern oder sogar Config Einstellung!!!
# tk_chooseDirectory
# tk_getOpenFile
# Config Ende
##################################################
class App: class App:
def __init__(self, master): def __init__(self, master):
@ -48,19 +28,18 @@ class App:
# global pathSave # global pathSave
# pathSave = "\\questions\\" + self.paradigmText # pathSave = "\\questions\\" + self.paradigmText
# pathSave = os.getcwd() + pathSave # pathSave = os.getcwd() + pathSave
config = configparser.ConfigParser() config.read('config.ini')
config.read('default.ini')
# Einstellung der GUI Größe # Einstellung der GUI Größe
textH = 4 textH = 4
textHsmall = 4 textHsmall = 2
textW = 20 textW = 20
def makeBtn(self, text, bg, command, side): def makeBtn(self, text, bg, command, side):
self.button = Button(frame, text=text, bg=bg, command=command) self.button = Button(frame, text=text, bg=bg, command=command)
self.button.config( height = textH, width = textW ) self.button.config( height = textH, width = textW )
self.button['font'] = tkFont.Font(family='Helvetica', size=36, weight='bold') self.button['font'] = tkFont.Font(family='Helvetica', size=16, weight='bold')
self.button.pack(side=side) self.button.pack(side=side)
return self.button return self.button
@ -75,13 +54,13 @@ class App:
frame.pack() frame.pack()
# button generation # button generation
self.Bfilter = makeBtnSmall(self, "1. Filter", "lightyellow", self.btn_filter, TOP) self.Bfilter = makeBtn(self, "1. Filter", "lightyellow", self.btn_filter, TOP)
self.BtacCal = makeBtnSmall(self, "2. Kalibrierung", "lightgreen", self.btn_tacCal, TOP) self.BtacCal = makeBtn(self, "2. Kalibrierung", "lightgreen", self.btn_tacCal, TOP)
self.Bp300 = makeBtnSmall(self, "3. P300 Klassifizierung", "orange", self.btn_p300, TOP) self.Bp300 = makeBtn(self, "3. P300 Klassifizierung", "orange", self.btn_p300, TOP)
self.BtacCopy = makeBtnSmall(self, "4. Freies Buchstabieren", "lightblue", self.btn_tacCopy, TOP) self.BtacCopy = makeBtn(self, "4. Freies Buchstabieren", "lightblue", self.btn_tacCopy, TOP)
self.BtacSimul = makeBtnSmall(self, "5. Rollstuhlsimulator", "pink", self.btn_tacSimul, TOP) self.BtacSimul = makeBtn(self, "5. Rollstuhlsimulator", "pink", self.btn_tacSimul, TOP)
# self.BtacQuest = makeBtnSmall(self, "6. Fragebogen", "green", self.btn_tacQuest, TOP) # self.BtacQuest = makeBtnSmall(self, "6. Fragebogen", "green", self.btn_tacQuest, TOP)
self.BtacSettings = makeBtnSmall(self, "Einstellungen", "gray", self.btn_settings, TOP) self.BtacConfig = makeBtnSmall(self, "Einstellungen", "gray", self.btn_config, TOP)
frame.rowconfigure((0,1), weight=1) # make buttons stretch when frame.rowconfigure((0,1), weight=1) # make buttons stretch when
frame.columnconfigure((0,2), weight=1) # when window is resized frame.columnconfigure((0,2), weight=1) # when window is resized
@ -91,38 +70,38 @@ class App:
# 1. FILTER ################################## # 1. FILTER ##################################
def btn_filter(self): def btn_filter(self):
print('Starte TactileBCIFilter.exe') print('Starte TactileBCIFilter.exe')
subprocess.Popen(pathTactileBciFilter + '\TactileBCIFilter.exe') subprocess.Popen(config['PATH']['TactileBCIFilter'] + '\TactileBCIFilter.exe')
# 2. KALIBIERUNGEN ########################### # 2. KALIBIERUNGEN ###########################
def btn_tacCal(self): def btn_tacCal(self):
print('starte taktile Kalibrierung') print('starte taktile Kalibrierung')
subprocess.Popen([pathBci2000 + '\prog\Operator.exe', '--OnConnect', '-LOAD PARAMETERFILE TactileCalibration.prm']) subprocess.Popen([config['PATH']['BCI2000'] + '\prog\Operator.exe', '--OnConnect', '-LOAD PARAMETERFILE TactileCalibration.prm'])
subprocess.Popen([pathBci2000 + '\prog\gUSBampSource.exe', '127.0.0.1']) subprocess.Popen([config['PATH']['BCI2000'] + '\prog\gUSBampSource.exe', '127.0.0.1'])
subprocess.Popen([pathBci2000 + '\prog\P3SignalProcessing.exe', '127.0.0.1']) subprocess.Popen([config['PATH']['BCI2000'] + '\prog\P3SignalProcessing.exe', '127.0.0.1'])
subprocess.Popen([pathBci2000 + '\prog\P3Speller.exe', '127.0.0.1']) subprocess.Popen([config['PATH']['BCI2000'] + '\prog\P3Speller.exe', '127.0.0.1'])
# TODO Lock einführen und bei Returnwert Lock öffnen # TODO Lock einführen und bei Returnwert Lock öffnen
# 3. P300 Classifier ######################### # 3. P300 Classifier #########################
def btn_p300(self): def btn_p300(self):
print('Starte P300Classifier.exe') print('Starte P300Classifier.exe')
subprocess.Popen(pathP300Classifier + '\P300Classifier.exe') subprocess.Popen(config['PATH']['P300Classifier'] + '\P300Classifier.exe')
# 4. COPYSPELL ########################### # 4. COPYSPELL ###########################
def btn_tacCopy(self): def btn_tacCopy(self):
print('Starte taktilen Copyspeller') print('Starte taktilen Copyspeller')
subprocess.Popen([pathBci2000 + '\prog\Operator.exe', '--OnConnect', '-LOAD PARAMETERFILE TactileCopy.prm']) subprocess.Popen([config['PATH']['BCI2000'] + '\prog\Operator.exe', '--OnConnect', '-LOAD PARAMETERFILE TactileCopy.prm'])
subprocess.Popen([pathBci2000 + '\prog\gUSBampSource.exe', '127.0.0.1']) subprocess.Popen([config['PATH']['BCI2000'] + '\prog\gUSBampSource.exe', '127.0.0.1'])
subprocess.Popen([pathBci2000 + '\prog\P3SignalProcessing.exe', '127.0.0.1']) subprocess.Popen([config['PATH']['BCI2000'] + '\prog\P3SignalProcessing.exe', '127.0.0.1'])
subprocess.Popen([pathBci2000 + '\prog\P3Speller.exe', '127.0.0.1']) subprocess.Popen([config['PATH']['BCI2000'] + '\prog\P3Speller.exe', '127.0.0.1'])
# 5. WHEELCHAIR SIMULATOR ########################### # 5. WHEELCHAIR SIMULATOR ###########################
def btn_tacSimul(self): def btn_tacSimul(self):
print('Starte Wheelchair Simulator') print('Starte Wheelchair Simulator')
# TODO Starte Wheelchair Simulator Programm # TODO Starte Wheelchair Simulator Programm
subprocess.Popen([pathBci2000 + '\prog\Operator.exe', '--OnConnect', '-LOAD PARAMETERFILE TactileDrive.prm']) # subprocess.Popen([pathBci2000 + '\prog\Operator.exe', '--OnConnect', '-LOAD PARAMETERFILE TactileDrive.prm'])
subprocess.Popen([pathBci2000 + '\prog\gUSBampSource.exe', '127.0.0.1']) # subprocess.Popen([pathBci2000 + '\prog\gUSBampSource.exe', '127.0.0.1'])
subprocess.Popen([pathBci2000 + '\prog\P3SignalProcessing.exe', '127.0.0.1']) # subprocess.Popen([pathBci2000 + '\prog\P3SignalProcessing.exe', '127.0.0.1'])
subprocess.Popen([pathBci2000 + '\prog\P3Speller.exe', '127.0.0.1']) # subprocess.Popen([pathBci2000 + '\prog\P3Speller.exe', '127.0.0.1'])
# QUESTIONNAIRE PROMPT ########################### # QUESTIONNAIRE PROMPT ###########################
# def btn_visQuest(self): # def btn_visQuest(self):
@ -146,14 +125,16 @@ class App:
# q.save() # q.save()
# X. Settings ######################### # X. Settings #########################
def btn_settings(self): def btn_config(self):
print('Einstellungen') print('Einstellungen')
# tk_chooseDirectory
# tk_getOpenFile
def global_close(self, window): def global_close(self, window):
print('Beenden') print('Beenden')
window.destroy() window.destroy()
config = configparser.ConfigParser()
root = Tk() root = Tk()
def on_closing(): def on_closing():