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 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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 os
  9. import subprocess
  10. # own code:
  11. # from questionnaire import quest
  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. # Config Ende
  24. ##################################################
  25. class App:
  26. def __init__(self, master):
  27. # self.paradigmText = sys.argv[1]
  28. # App.paradigmText = sys.argv[1]
  29. # print sys.argv[1]
  30. # pathOrigin = os.path.dirname(os.path.realpath(__file__))
  31. # TODO current working directory auf root von dieser file setzen
  32. # global pathSave
  33. # pathSave = "\\questions\\" + self.paradigmText
  34. # pathSave = os.getcwd() + pathSave
  35. # Einstellung der GUI Größe
  36. textH = 4
  37. textHsmall = 4
  38. textW = 20
  39. def makeBtn(self, text, bg, command, side):
  40. self.button = Button(frame, text=text, bg=bg, command=command)
  41. self.button.config( height = textH, width = textW )
  42. self.button['font'] = tkFont.Font(family='Helvetica', size=36, weight='bold')
  43. self.button.pack(side=side)
  44. return self.button
  45. def makeBtnSmall(self, text, bg, command, side):
  46. self.button = Button(frame, text=text, bg=bg, command=command)
  47. self.button.config( height = textHsmall, width = textW )
  48. self.button['font'] = tkFont.Font(family='Helvetica', size=16, weight='bold')
  49. self.button.pack(side=side)
  50. return self.button
  51. frame = Frame(master)
  52. frame.pack()
  53. # button generation
  54. self.Bfilter = makeBtnSmall(self, "1. Filter", "lightyellow", self.btn_filter, TOP)
  55. self.BtacCal = makeBtnSmall(self, "2. Kalibrierung", "lightgreen", self.btn_tacCal, TOP)
  56. self.Bp300 = makeBtnSmall(self, "3. P300 Klassifizierung", "orange", self.btn_p300, TOP)
  57. self.BtacCopy = makeBtnSmall(self, "4. Freies Buchstabieren", "lightblue", self.btn_tacCopy, TOP)
  58. # self.BtacQuest = makeBtnSmall(self, "5. Fragebogen", "pink", self.btn_tacQuest, TOP)
  59. self.BtacSettings = makeBtnSmall(self, "Einstellungen", "gray", self.btn_settings, TOP)
  60. frame.rowconfigure((0,1), weight=1) # make buttons stretch when
  61. frame.columnconfigure((0,2), weight=1) # when window is resized
  62. # TODO Hilfestellung nach jedem Button aufploppen lassen:
  63. # Was tun? Wo klicken? Welche File wo laden?
  64. # 1. FILTER ##################################
  65. def btn_filter(self):
  66. print('Starte TactileBCIFilter.exe')
  67. subprocess.Popen(pathTactileBciFilter + '\TactileBCIFilter.exe')
  68. # 2. KALIBIERUNGEN ###########################
  69. def btn_tacCal(self):
  70. print('starte taktile Kalibrierung')
  71. subprocess.Popen([pathBci2000 + '\prog\Operator.exe', '--OnConnect', '-LOAD PARAMETERFILE TactileCalibration.prm'])
  72. subprocess.Popen([pathBci2000 + '\prog\gUSBampSource.exe', '127.0.0.1'])
  73. subprocess.Popen([pathBci2000 + '\prog\P3SignalProcessing.exe', '127.0.0.1'])
  74. subprocess.Popen([pathBci2000 + '\prog\P3Speller.exe', '127.0.0.1'])
  75. # TODO Lock einführen und bei Returnwert Lock öffnen
  76. # 3. P300 Classifier #########################
  77. def btn_p300(self):
  78. print('Starte P300Classifier.exe')
  79. subprocess.Popen(pathP300Classifier + '\P300Classifier.exe')
  80. # 3. COPYSPELL ###########################
  81. def btn_tacCopy(self):
  82. print('Starte taktilen Copyspeller')
  83. # os.system('bin\WT-tacCopy.bat')
  84. subprocess.Popen([pathBci2000 + '\prog\Operator.exe', '--OnConnect', '-LOAD PARAMETERFILE TactileCopy.prm'])
  85. subprocess.Popen([pathBci2000 + '\prog\gUSBampSource.exe', '127.0.0.1'])
  86. subprocess.Popen([pathBci2000 + '\prog\P3SignalProcessing.exe', '127.0.0.1'])
  87. subprocess.Popen([pathBci2000 + '\prog\P3Speller.exe', '127.0.0.1'])
  88. # QUESTIONNAIRE PROMPT ###########################
  89. # def btn_visQuest(self):
  90. # #os.system('python .\PythonBCIgui\q-helper.py ' + "Visual")
  91. # root.destroy()
  92. # self.startQuestions("Visual")
  93. # def btn_tacQuest(self):
  94. # root.destroy()
  95. # self.startQuestions("Tactile")
  96. # def btn_audQuest(self):
  97. # root.destroy()
  98. # self.startQuestions("Auditory")
  99. # def startQuestions(self, para):
  100. # print('starte Fragebogen')
  101. # # TODO
  102. # # q = quest(para)
  103. # # q.qSatisfaction()
  104. # # q.qExhaustion()
  105. # # q.qSubjControl()
  106. # # q.qCtrlChange()
  107. # # q.save()
  108. # 3. P300 Classifier #########################
  109. def btn_settings(self):
  110. print('Einstellungen')
  111. def global_close(self, window):
  112. print('Beenden')
  113. window.destroy()
  114. root = Tk()
  115. def on_closing():
  116. #self.global_close(root)
  117. print('Beenden')
  118. root.destroy()
  119. root.protocol("WM_DELETE_WINDOW", on_closing)
  120. app = App(root)
  121. root.mainloop()
  122. #root.destroy() # optional;