You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

app.py 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Fri Sep 4 11:36:24 2020
  4. @author: Igor Beloschapkin
  5. """
  6. from tkinter import *
  7. import tkinter.font as tkFont
  8. import subprocess
  9. import configparser
  10. # own code:
  11. # from questionnaire import quest
  12. # TODO Eventuell updatefunktion über git pull mit einbauen!
  13. ##################################################
  14. # Config Beginn
  15. # Folgende Strings bitte an jeweiligen PC anpassen
  16. # in folgendem Format: variable = r'C:\Pfad' ("r" vor Pfad nicht vergessen!!!)
  17. # Hier findet man die Ordner batch, data, icons, parms, prog, tools
  18. pathBci2000 = r'C:\BCI2000\BCI2000 v3.6.beta.R5570\BCI2000.x64'
  19. # Hier findet man den TactileBCIFilter.exe
  20. pathTactileBciFilter = r'C:\Users\bci\Desktop\Qt Filter Program\build-TactileBCIFilter-Desktop_Qt_5_15_0_MinGW_32_bit-Release\release'
  21. # Hier findet man die P300Classifier.exe
  22. pathP300Classifier = r'C:\Users\bci\Desktop\Igor\PythonBCIgui_v0.2\bin'
  23. # TODO Config in txt file verlagern oder sogar Config Einstellung!!!
  24. # tk_chooseDirectory
  25. # tk_getOpenFile
  26. # Config Ende
  27. ##################################################
  28. class App:
  29. def __init__(self, master):
  30. # self.paradigmText = sys.argv[1]
  31. # App.paradigmText = sys.argv[1]
  32. # print sys.argv[1]
  33. # pathOrigin = os.path.dirname(os.path.realpath(__file__))
  34. # TODO current working directory auf root von dieser file setzen
  35. # global pathSave
  36. # pathSave = "\\questions\\" + self.paradigmText
  37. # pathSave = os.getcwd() + pathSave
  38. config = configparser.ConfigParser()
  39. config.read('default.ini')
  40. # Einstellung der GUI Größe
  41. textH = 4
  42. textHsmall = 4
  43. textW = 20
  44. def makeBtn(self, text, bg, command, side):
  45. self.button = Button(frame, text=text, bg=bg, command=command)
  46. self.button.config( height = textH, width = textW )
  47. self.button['font'] = tkFont.Font(family='Helvetica', size=36, weight='bold')
  48. self.button.pack(side=side)
  49. return self.button
  50. def makeBtnSmall(self, text, bg, command, side):
  51. self.button = Button(frame, text=text, bg=bg, command=command)
  52. self.button.config( height = textHsmall, width = textW )
  53. self.button['font'] = tkFont.Font(family='Helvetica', size=16, weight='bold')
  54. self.button.pack(side=side)
  55. return self.button
  56. frame = Frame(master)
  57. frame.pack()
  58. # button generation
  59. self.Bfilter = makeBtnSmall(self, "1. Filter", "lightyellow", self.btn_filter, TOP)
  60. self.BtacCal = makeBtnSmall(self, "2. Kalibrierung", "lightgreen", self.btn_tacCal, TOP)
  61. self.Bp300 = makeBtnSmall(self, "3. P300 Klassifizierung", "orange", self.btn_p300, TOP)
  62. self.BtacCopy = makeBtnSmall(self, "4. Freies Buchstabieren", "lightblue", self.btn_tacCopy, TOP)
  63. self.BtacSimul = makeBtnSmall(self, "5. Rollstuhlsimulator", "pink", self.btn_tacSimul, TOP)
  64. # self.BtacQuest = makeBtnSmall(self, "6. Fragebogen", "green", self.btn_tacQuest, TOP)
  65. self.BtacSettings = makeBtnSmall(self, "Einstellungen", "gray", self.btn_settings, TOP)
  66. frame.rowconfigure((0,1), weight=1) # make buttons stretch when
  67. frame.columnconfigure((0,2), weight=1) # when window is resized
  68. # TODO Hilfestellung nach jedem Button aufploppen lassen:
  69. # Was tun? Wo klicken? Welche File wo laden?
  70. # 1. FILTER ##################################
  71. def btn_filter(self):
  72. print('Starte TactileBCIFilter.exe')
  73. subprocess.Popen(pathTactileBciFilter + '\TactileBCIFilter.exe')
  74. # 2. KALIBIERUNGEN ###########################
  75. def btn_tacCal(self):
  76. print('starte taktile Kalibrierung')
  77. subprocess.Popen([pathBci2000 + '\prog\Operator.exe', '--OnConnect', '-LOAD PARAMETERFILE TactileCalibration.prm'])
  78. subprocess.Popen([pathBci2000 + '\prog\gUSBampSource.exe', '127.0.0.1'])
  79. subprocess.Popen([pathBci2000 + '\prog\P3SignalProcessing.exe', '127.0.0.1'])
  80. subprocess.Popen([pathBci2000 + '\prog\P3Speller.exe', '127.0.0.1'])
  81. # TODO Lock einführen und bei Returnwert Lock öffnen
  82. # 3. P300 Classifier #########################
  83. def btn_p300(self):
  84. print('Starte P300Classifier.exe')
  85. subprocess.Popen(pathP300Classifier + '\P300Classifier.exe')
  86. # 4. COPYSPELL ###########################
  87. def btn_tacCopy(self):
  88. print('Starte taktilen Copyspeller')
  89. subprocess.Popen([pathBci2000 + '\prog\Operator.exe', '--OnConnect', '-LOAD PARAMETERFILE TactileCopy.prm'])
  90. subprocess.Popen([pathBci2000 + '\prog\gUSBampSource.exe', '127.0.0.1'])
  91. subprocess.Popen([pathBci2000 + '\prog\P3SignalProcessing.exe', '127.0.0.1'])
  92. subprocess.Popen([pathBci2000 + '\prog\P3Speller.exe', '127.0.0.1'])
  93. # 5. WHEELCHAIR SIMULATOR ###########################
  94. def btn_tacSimul(self):
  95. print('Starte Wheelchair Simulator')
  96. # TODO Starte Wheelchair Simulator Programm
  97. subprocess.Popen([pathBci2000 + '\prog\Operator.exe', '--OnConnect', '-LOAD PARAMETERFILE TactileDrive.prm'])
  98. subprocess.Popen([pathBci2000 + '\prog\gUSBampSource.exe', '127.0.0.1'])
  99. subprocess.Popen([pathBci2000 + '\prog\P3SignalProcessing.exe', '127.0.0.1'])
  100. subprocess.Popen([pathBci2000 + '\prog\P3Speller.exe', '127.0.0.1'])
  101. # QUESTIONNAIRE PROMPT ###########################
  102. # def btn_visQuest(self):
  103. # #os.system('python .\PythonBCIgui\q-helper.py ' + "Visual")
  104. # root.destroy()
  105. # self.startQuestions("Visual")
  106. # def btn_tacQuest(self):
  107. #root.destroy()
  108. # self.startQuestions("Tactile")
  109. # def btn_audQuest(self):
  110. # root.destroy()
  111. # self.startQuestions("Auditory")
  112. # def startQuestions(self, para):
  113. # print('Starte Fragebogen')
  114. # q = quest(para)
  115. # q.qSatisfaction()
  116. # q.qExhaustion()
  117. # q.qSubjControl()
  118. # q.qCtrlChange()
  119. # q.save()
  120. # X. Settings #########################
  121. def btn_settings(self):
  122. print('Einstellungen')
  123. def global_close(self, window):
  124. print('Beenden')
  125. window.destroy()
  126. root = Tk()
  127. def on_closing():
  128. #self.global_close(root)
  129. print('Beenden')
  130. root.destroy()
  131. root.protocol("WM_DELETE_WINDOW", on_closing)
  132. app = App(root)
  133. root.mainloop()
  134. #root.destroy() # optional;