Implement Python3 Functionality Fixes

This commit is contained in:
bci 2020-09-04 13:06:21 +02:00
parent ed0faa2c7a
commit 237ce7e164

67
app.py
View File

@ -2,15 +2,15 @@
""" """
Created on Fri Sep 4 11:36:24 2020 Created on Fri Sep 4 11:36:24 2020
@author: @author:
V0.1 Matthias Eidel V0.1 Matthias Eidel
V0.2 Igor Beloschapkin V0.2 Igor Beloschapkin
V0.3 Igor Beloschapkin V0.3 Igor Beloschapkin
""" """
from Tkinter import * from tkinter import *
import tkFont import tkinter.font as tkFont
import tkMessageBox #import tkMessageBox
import os import os
# own code: # own code:
@ -37,22 +37,20 @@ pathP300Classifier = r'C:\Users\bci\Desktop\Igor\PythonBCIgui_v0.2\bin'
class App: class App:
def __init__(self, master): def __init__(self, master):
global lastType # self.paradigmText = sys.argv[1]
lastType = "NONE" # App.paradigmText = sys.argv[1]
self.paradigmText = sys.argv[1] # print sys.argv[1]
App.paradigmText = sys.argv[1] # pathOrigin = os.path.dirname(os.path.realpath(__file__))
#print sys.argv[1]
pathOrigin = os.path.dirname(os.path.realpath(__file__)) # global pathSave
# pathSave = "\\questions\\" + self.paradigmText
global pathSave # pathSave = os.getcwd() + pathSave
pathSave = "\\questions\\" + self.paradigmText
pathSave = os.getcwd() + pathSave
textH = 2 textH = 2
textHsmall = 2 textHsmall = 2
textW = 8 textW = 8
def makeBtn(self, text, bg, command, side): def makeBtn(self, text, bg, command, side):
self.button = Button(frame, text=text, bg=bg, command=command) self.button = Button(frame, text=text, bg=bg, command=command)
self.button.config( height = textH, width = textW ) self.button.config( height = textH, width = textW )
@ -64,14 +62,14 @@ class App:
self.button = Button(frame, text=text, bg=bg, command=command) self.button = Button(frame, text=text, bg=bg, command=command)
self.button.config( height = textHsmall, width = textW ) self.button.config( height = textHsmall, width = textW )
self.button['font'] = tkFont.Font(family='Helvetica', size=16, weight='bold') self.button['font'] = tkFont.Font(family='Helvetica', size=16, weight='bold')
self.button.pack(side=side) self.button.pack(side=side)
return self.button return self.button
frame = Frame(master) frame = Frame(master)
frame.pack() frame.pack()
# button generation # button generation
self.BtacControl = makeBtn(self, "1. Control", "lightblue", self.btn_tacControl, LEFT) self.Bfilter = makeBtn(self, "1. Filter", "lightblue", self.btn_filter, LEFT)
self.BtacCal = makeBtn(self, "2. Calibrate", "lightblue", self.btn_tacCal, LEFT) self.BtacCal = makeBtn(self, "2. Calibrate", "lightblue", self.btn_tacCal, LEFT)
self.Bp300 = makeBtn(self, "3. P300 Classifier", "lightblue", self.btn_p300, LEFT) self.Bp300 = makeBtn(self, "3. P300 Classifier", "lightblue", self.btn_p300, LEFT)
self.BtacCopy = makeBtn(self, "Tactile Copy", "lightblue", self.btn_tacCopy, LEFT) self.BtacCopy = makeBtn(self, "Tactile Copy", "lightblue", self.btn_tacCopy, LEFT)
@ -79,15 +77,15 @@ class App:
frame.rowconfigure((0,1), weight=1) # make buttons stretch when frame.rowconfigure((0,1), weight=1) # make buttons stretch when
frame.columnconfigure((0,2), weight=1) # when window is resized frame.columnconfigure((0,2), weight=1) # when window is resized
self.BtacControl.grid(row=0, column=0, columnspan=1, sticky='EWNS') # self.Bfilter.grid(row=0, column=0, columnspan=1, sticky='EWNS')
self.BtacCal.grid(row=1, column=0, columnspan=1, sticky='EWNS') # self.BtacCal.grid(row=1, column=0, columnspan=1, sticky='EWNS')
self.Bp300.grid(row=2, column=0, columnspan=1, sticky='EWNS') # self.Bp300.grid(row=2, column=0, columnspan=1, sticky='EWNS')
self.BtacCopy.grid(row=3, column=0, columnspan=1, sticky='EWNS') # self.BtacCopy.grid(row=3, column=0, columnspan=1, sticky='EWNS')
self.BtacQuest.grid(row=4, column=0, columnspan=1, sticky='EWNS') # self.BtacQuest.grid(row=4, column=0, columnspan=1, sticky='EWNS')
# 1. FILTER ################################## # 1. FILTER ##################################
def btn_tactorControl(self): def btn_filter(self):
print('Starte TactileBCIFilter.exe') print('Starte TactileBCIFilter.exe')
os.startfile(pathTactileBciFilter + '\TactileBCIFilter.exe') os.startfile(pathTactileBciFilter + '\TactileBCIFilter.exe')
@ -116,7 +114,7 @@ class App:
self.startQuestions("Tactile") self.startQuestions("Tactile")
# def btn_audQuest(self): # def btn_audQuest(self):
# root.destroy() # root.destroy()
# self.startQuestions("Auditory") # self.startQuestions("Auditory")
def startQuestions(self, para): def startQuestions(self, para):
print('starte Fragebogen') print('starte Fragebogen')
@ -130,11 +128,16 @@ class App:
def global_close(self, window): def global_close(self, window):
print('quitting?') print('quitting?')
if tkMessageBox.askokcancel("Quit", "Nach einer BCI Sitzung bitte an den Fragebogen denken! :) OK zum Beenden."): window.destroy()
window.destroy()
root = Tk() root = Tk()
def on_closing():
#self.global_close(root)
print('quitting?')
root.destroy()
root.protocol("WM_DELETE_WINDOW", on_closing) root.protocol("WM_DELETE_WINDOW", on_closing)
app = App(root) app = App(root)
root.mainloop() root.mainloop()