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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Fri Sep 4 11:36:24 2020
  4. @author:
  5. V0.1 Matthias Eidel
  6. V0.2 Igor Beloschapkin
  7. V0.3 Igor Beloschapkin
  8. """
  9. from Tkinter import *
  10. import tkFont
  11. import tkMessageBox
  12. import os
  13. # own code:
  14. # from questionnaire import quest
  15. ##################################################
  16. # Config Beginn
  17. # Folgende Strings bitte an jeweiligen PC anpassen
  18. # in folgendem Format: variable = r'C:\Pfad' ("r" vor Pfad nicht vergessen!!!)
  19. # Hier findet man die Ordner batch, data, icons, parms, prog, tools
  20. pathBci2000 = r'C:\BCI2000\BCI2000 v3.6.beta.R5570\BCI2000.x64'
  21. # Hier findet man den TactileBCIFilter.exe
  22. pathTactileBciFilter = r'C:\Users\bci\Desktop\Qt Filter Program\build-TactileBCIFilter-Desktop_Qt_5_15_0_MinGW_32_bit-Release\release'
  23. # Hier findet man die P300Classifier.exe
  24. pathP300Classifier = r'C:\Users\bci\Desktop\Igor\PythonBCIgui_v0.2\bin'
  25. # TODO Config in txt file verlagern
  26. # Config Ende
  27. ##################################################
  28. class App:
  29. def __init__(self, master):
  30. global lastType
  31. lastType = "NONE"
  32. self.paradigmText = sys.argv[1]
  33. App.paradigmText = sys.argv[1]
  34. #print sys.argv[1]
  35. pathOrigin = os.path.dirname(os.path.realpath(__file__))
  36. global pathSave
  37. pathSave = "\\questions\\" + self.paradigmText
  38. pathSave = os.getcwd() + pathSave
  39. textH = 2
  40. textHsmall = 2
  41. textW = 8
  42. def makeBtn(self, text, bg, command, side):
  43. self.button = Button(frame, text=text, bg=bg, command=command)
  44. self.button.config( height = textH, width = textW )
  45. self.button['font'] = tkFont.Font(family='Helvetica', size=36, weight='bold')
  46. self.button.pack(side=side)
  47. return self.button
  48. def makeBtnSmall(self, text, bg, command, side):
  49. self.button = Button(frame, text=text, bg=bg, command=command)
  50. self.button.config( height = textHsmall, width = textW )
  51. self.button['font'] = tkFont.Font(family='Helvetica', size=16, weight='bold')
  52. self.button.pack(side=side)
  53. return self.button
  54. frame = Frame(master)
  55. frame.pack()
  56. # button generation
  57. self.BtacControl = makeBtn(self, "1. Control", "lightblue", self.btn_tacControl, LEFT)
  58. self.BtacCal = makeBtn(self, "2. Calibrate", "lightblue", self.btn_tacCal, LEFT)
  59. self.Bp300 = makeBtn(self, "3. P300 Classifier", "lightblue", self.btn_p300, LEFT)
  60. self.BtacCopy = makeBtn(self, "Tactile Copy", "lightblue", self.btn_tacCopy, LEFT)
  61. self.BtacQuest = makeBtnSmall(self, "Fragebogen", "lightgreen", self.btn_tacQuest, LEFT)
  62. frame.rowconfigure((0,1), weight=1) # make buttons stretch when
  63. frame.columnconfigure((0,2), weight=1) # when window is resized
  64. self.BtacControl.grid(row=0, column=0, columnspan=1, sticky='EWNS')
  65. self.BtacCal.grid(row=1, column=0, columnspan=1, sticky='EWNS')
  66. self.Bp300.grid(row=2, column=0, columnspan=1, sticky='EWNS')
  67. self.BtacCopy.grid(row=3, column=0, columnspan=1, sticky='EWNS')
  68. self.BtacQuest.grid(row=4, column=0, columnspan=1, sticky='EWNS')
  69. # 1. FILTER ##################################
  70. def btn_tactorControl(self):
  71. print('Starte TactileBCIFilter.exe')
  72. os.startfile(pathTactileBciFilter + '\TactileBCIFilter.exe')
  73. # 2. KALIBIERUNGEN ###########################
  74. def btn_tacCal(self):
  75. print('starte taktile kalibrierung')
  76. os.system('bin\WT-tacCalib.bat')
  77. # 3. P300 Classifier #########################
  78. def btn_p300(self):
  79. print('Starte P300 Classifier')
  80. os.startfile(pathP300Classifier + '\P300Classifier.exe')
  81. # 3. COPYSPELL ###########################
  82. def btn_tacCopy(self):
  83. print('starte tactile bci')
  84. os.system('bin\WT-tacCopy.bat')
  85. # QUESTIONNAIRE PROMPT ###########################
  86. # def btn_visQuest(self):
  87. # #os.system('python .\PythonBCIgui\q-helper.py ' + "Visual")
  88. # root.destroy()
  89. # self.startQuestions("Visual")
  90. def btn_tacQuest(self):
  91. root.destroy()
  92. self.startQuestions("Tactile")
  93. # def btn_audQuest(self):
  94. # root.destroy()
  95. # self.startQuestions("Auditory")
  96. def startQuestions(self, para):
  97. print('starte Fragebogen')
  98. # TODO
  99. # q = quest(para)
  100. # q.qSatisfaction()
  101. # q.qExhaustion()
  102. # q.qSubjControl()
  103. # q.qCtrlChange()
  104. # q.save()
  105. def global_close(self, window):
  106. print('quitting?')
  107. if tkMessageBox.askokcancel("Quit", "Nach einer BCI Sitzung bitte an den Fragebogen denken! :) OK zum Beenden."):
  108. window.destroy()
  109. root = Tk()
  110. root.protocol("WM_DELETE_WINDOW", on_closing)
  111. app = App(root)
  112. root.mainloop()
  113. #root.destroy() # optional;