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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. class App:
  14. def __init__(self, master):
  15. # self.paradigmText = sys.argv[1]
  16. # App.paradigmText = sys.argv[1]
  17. # print sys.argv[1]
  18. # pathOrigin = os.path.dirname(os.path.realpath(__file__))
  19. # TODO current working directory auf root von dieser file setzen
  20. # global pathSave
  21. # pathSave = "\\questions\\" + self.paradigmText
  22. # pathSave = os.getcwd() + pathSave
  23. config.read('config.ini')
  24. # Einstellung der GUI Größe
  25. textH = 4
  26. textHsmall = 2
  27. textW = 20
  28. def makeBtn(self, text, bg, command, side):
  29. self.button = Button(frame, text=text, bg=bg, command=command)
  30. self.button.config( height = textH, width = textW )
  31. self.button['font'] = tkFont.Font(family='Helvetica', size=16, weight='bold')
  32. self.button.pack(side=side)
  33. return self.button
  34. def makeBtnSmall(self, text, bg, command, side):
  35. self.button = Button(frame, text=text, bg=bg, command=command)
  36. self.button.config( height = textHsmall, width = textW )
  37. self.button['font'] = tkFont.Font(family='Helvetica', size=16, weight='bold')
  38. self.button.pack(side=side)
  39. return self.button
  40. frame = Frame(master)
  41. frame.pack()
  42. # button generation
  43. self.Bfilter = makeBtn(self, "1. Filter", "lightyellow", self.btn_filter, TOP)
  44. self.BtacCal = makeBtn(self, "2. Kalibrierung", "lightgreen", self.btn_tacCal, TOP)
  45. self.Bp300 = makeBtn(self, "3. P300 Klassifizierung", "orange", self.btn_p300, TOP)
  46. self.BtacCopy = makeBtn(self, "4. Freies Buchstabieren", "lightblue", self.btn_tacCopy, TOP)
  47. self.BtacSimul = makeBtn(self, "5. Rollstuhlsimulator", "pink", self.btn_tacSimul, TOP)
  48. # self.BtacQuest = makeBtnSmall(self, "6. Fragebogen", "green", self.btn_tacQuest, TOP)
  49. self.BtacConfig = makeBtnSmall(self, "Einstellungen", "gray", self.btn_config, TOP)
  50. frame.rowconfigure((0,1), weight=1) # make buttons stretch when
  51. frame.columnconfigure((0,2), weight=1) # when window is resized
  52. # TODO Hilfestellung nach jedem Button aufploppen lassen:
  53. # Was tun? Wo klicken? Welche File wo laden?
  54. # 1. FILTER ##################################
  55. def btn_filter(self):
  56. print('Starte TactileBCIFilter.exe')
  57. subprocess.Popen(config['PATH']['TactileBCIFilter'] + '\TactileBCIFilter.exe')
  58. # 2. KALIBIERUNGEN ###########################
  59. def btn_tacCal(self):
  60. print('starte taktile Kalibrierung')
  61. subprocess.Popen([config['PATH']['BCI2000'] + '\prog\Operator.exe', '--OnConnect', '-LOAD PARAMETERFILE TactileCalibration.prm'])
  62. subprocess.Popen([config['PATH']['BCI2000'] + '\prog\gUSBampSource.exe', '127.0.0.1'])
  63. subprocess.Popen([config['PATH']['BCI2000'] + '\prog\P3SignalProcessing.exe', '127.0.0.1'])
  64. subprocess.Popen([config['PATH']['BCI2000'] + '\prog\P3Speller.exe', '127.0.0.1'])
  65. # TODO Lock einführen und bei Returnwert Lock öffnen
  66. # 3. P300 Classifier #########################
  67. def btn_p300(self):
  68. print('Starte P300Classifier.exe')
  69. subprocess.Popen(config['PATH']['P300Classifier'] + '\P300Classifier.exe')
  70. # 4. COPYSPELL ###########################
  71. def btn_tacCopy(self):
  72. print('Starte taktilen Copyspeller')
  73. subprocess.Popen([config['PATH']['BCI2000'] + '\prog\Operator.exe', '--OnConnect', '-LOAD PARAMETERFILE TactileCopy.prm'])
  74. subprocess.Popen([config['PATH']['BCI2000'] + '\prog\gUSBampSource.exe', '127.0.0.1'])
  75. subprocess.Popen([config['PATH']['BCI2000'] + '\prog\P3SignalProcessing.exe', '127.0.0.1'])
  76. subprocess.Popen([config['PATH']['BCI2000'] + '\prog\P3Speller.exe', '127.0.0.1'])
  77. # 5. WHEELCHAIR SIMULATOR ###########################
  78. def btn_tacSimul(self):
  79. print('Starte Wheelchair Simulator')
  80. # TODO Starte Wheelchair Simulator Programm
  81. # subprocess.Popen([pathBci2000 + '\prog\Operator.exe', '--OnConnect', '-LOAD PARAMETERFILE TactileDrive.prm'])
  82. # subprocess.Popen([pathBci2000 + '\prog\gUSBampSource.exe', '127.0.0.1'])
  83. # subprocess.Popen([pathBci2000 + '\prog\P3SignalProcessing.exe', '127.0.0.1'])
  84. # subprocess.Popen([pathBci2000 + '\prog\P3Speller.exe', '127.0.0.1'])
  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. # q = quest(para)
  99. # q.qSatisfaction()
  100. # q.qExhaustion()
  101. # q.qSubjControl()
  102. # q.qCtrlChange()
  103. # q.save()
  104. # X. Settings #########################
  105. def btn_config(self):
  106. print('Einstellungen')
  107. # tk_chooseDirectory
  108. # tk_getOpenFile
  109. def global_close(self, window):
  110. print('Beenden')
  111. window.destroy()
  112. config = configparser.ConfigParser()
  113. root = Tk()
  114. def on_closing():
  115. #self.global_close(root)
  116. print('Beenden')
  117. root.destroy()
  118. root.protocol("WM_DELETE_WINDOW", on_closing)
  119. app = App(root)
  120. root.mainloop()
  121. #root.destroy() # optional;