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.2KB

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