123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- # -*- coding: utf-8 -*-
- """
- Created on Fri Sep 4 11:36:24 2020
-
- @author: Igor Beloschapkin
- """
-
- from tkinter import *
- import tkinter.font as tkFont
- import subprocess
- import configparser
-
- # own code:
- # from questionnaire import quest
-
- # TODO Eventuell updatefunktion über git pull mit einbauen!
-
- class App:
-
- def __init__(self, master):
- # self.paradigmText = sys.argv[1]
- # App.paradigmText = sys.argv[1]
- # print sys.argv[1]
- # pathOrigin = os.path.dirname(os.path.realpath(__file__))
-
- # TODO current working directory auf root von dieser file setzen
-
- # global pathSave
- # pathSave = "\\questions\\" + self.paradigmText
- # pathSave = os.getcwd() + pathSave
-
- config.read('config.ini')
-
- # Einstellung der GUI Größe
- textH = 4
- textHsmall = 2
- textW = 20
-
- def makeBtn(self, text, bg, command, side):
- self.button = Button(frame, text=text, bg=bg, command=command)
- self.button.config( height = textH, width = textW )
- self.button['font'] = tkFont.Font(family='Helvetica', size=16, weight='bold')
- self.button.pack(side=side)
- return self.button
-
- def makeBtnSmall(self, text, bg, command, side):
- self.button = Button(frame, text=text, bg=bg, command=command)
- self.button.config( height = textHsmall, width = textW )
- self.button['font'] = tkFont.Font(family='Helvetica', size=16, weight='bold')
- self.button.pack(side=side)
- return self.button
-
- frame = Frame(master)
- frame.pack()
-
- # button generation
- self.Bfilter = makeBtn(self, "1. Filter", "lightyellow", self.btn_filter, TOP)
- self.BtacCal = makeBtn(self, "2. Kalibrierung", "lightgreen", self.btn_tacCal, TOP)
- self.Bp300 = makeBtn(self, "3. P300 Klassifizierung", "orange", self.btn_p300, TOP)
- self.BtacCopy = makeBtn(self, "4. Freies Buchstabieren", "lightblue", self.btn_tacCopy, TOP)
- self.BtacSimul = makeBtn(self, "5. Rollstuhlsimulator", "pink", self.btn_tacSimul, TOP)
- # self.BtacQuest = makeBtnSmall(self, "6. Fragebogen", "green", self.btn_tacQuest, TOP)
- self.BtacConfig = makeBtnSmall(self, "Konfiguration", "gray", self.btn_config, TOP)
-
- frame.rowconfigure((0,1), weight=1) # make buttons stretch when
- frame.columnconfigure((0,2), weight=1) # when window is resized
- # TODO Hilfestellung nach jedem Button aufploppen lassen:
- # Was tun? Wo klicken? Welche File wo laden?
-
- # 1. FILTER ##################################
- def btn_filter(self):
- print('Starte TactileBCIFilter.exe')
- subprocess.Popen(config['PATH']['tactilebcifilter'] + '\TactileBCIFilter.exe')
-
- # 2. KALIBIERUNGEN ###########################
- def btn_tacCal(self):
- print('starte taktile Kalibrierung')
- subprocess.Popen([config['PATH']['bci2000'] + r'\prog\Operator.exe', '--OnConnect', '-LOAD PARAMETERFILE TactileCalibration.prm'])
- subprocess.Popen([config['PATH']['bci2000'] + r'\prog\gUSBampSource.exe', '127.0.0.1'])
- subprocess.Popen([config['PATH']['bci2000'] + r'\prog\P3SignalProcessing.exe', '127.0.0.1'])
- subprocess.Popen([config['PATH']['bci2000'] + r'\prog\P3Speller.exe', '127.0.0.1'])
- # TODO Lock einführen und bei Returnwert Lock öffnen
-
- # 3. P300 Classifier #########################
- def btn_p300(self):
- print('Starte P300Classifier.exe')
- subprocess.Popen(config['PATH']['bci2000'] + r'\tools\P300Classifier\P300Classifier.exe')
-
- # 4. COPYSPELL ###########################
- def btn_tacCopy(self):
- print('Starte taktilen Copyspeller')
- subprocess.Popen([config['PATH']['bci2000'] + r'\prog\Operator.exe', '--OnConnect', '-LOAD PARAMETERFILE TactileCopy.prm'])
- subprocess.Popen([config['PATH']['bci2000'] + r'\prog\gUSBampSource.exe', '127.0.0.1'])
- subprocess.Popen([config['PATH']['bci2000'] + r'\prog\P3SignalProcessing.exe', '127.0.0.1'])
- subprocess.Popen([config['PATH']['bci2000'] + r'\prog\P3Speller.exe', '127.0.0.1'])
-
- # 5. WHEELCHAIR SIMULATOR ###########################
- def btn_tacSimul(self):
- print('Starte Wheelchair Simulator')
- # TODO Starte Wheelchair Simulator Programm
- # 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\P3SignalProcessing.exe', '127.0.0.1'])
- # subprocess.Popen([pathBci2000 + '\prog\P3Speller.exe', '127.0.0.1'])
-
- # QUESTIONNAIRE PROMPT ###########################
- # def btn_visQuest(self):
- # #os.system('python .\PythonBCIgui\q-helper.py ' + "Visual")
- # root.destroy()
- # self.startQuestions("Visual")
- # def btn_tacQuest(self):
- #root.destroy()
- # self.startQuestions("Tactile")
- # def btn_audQuest(self):
- # root.destroy()
- # self.startQuestions("Auditory")
-
- # def startQuestions(self, para):
- # print('Starte Fragebogen')
- # q = quest(para)
- # q.qSatisfaction()
- # q.qExhaustion()
- # q.qSubjControl()
- # q.qCtrlChange()
- # q.save()
-
- # X. Settings #########################
- def btn_config(self):
- print('Konfiguration')
- messagebox.showinfo('Konfiguration', 'Bitte wählen Sie nun den BCI2000 Ordner aus, in dem sich die Ordner "batch", "data", "icons", "parms", "prog" und "tools" befinden.')
- config['PATH']['bci2000'] = filedialog.askdirectory()
- messagebox.showinfo('Konfiguration', 'Bitte wählen Sie nun den Ordner aus, in dem sich die TactileBCIfilter.exe befindet.')
- config['PATH']['tactilebcifilter'] = filedialog.askdirectory()
- config.write(open('config.ini','w'))
- # TODO Catch errors falls falsche Ordner gewählt wurden
-
- def global_close(self, window):
- print('Beenden')
- window.destroy()
-
- config = configparser.ConfigParser()
- root = Tk()
-
- def on_closing():
- #self.global_close(root)
- print('Beenden')
- root.destroy()
-
- root.protocol("WM_DELETE_WINDOW", on_closing)
- app = App(root)
- root.mainloop()
- #root.destroy() # optional;
|