Browse Source

Fix tkinter import

master
Igor Beloschapkin 3 years ago
parent
commit
37df6d1884
1 changed files with 29 additions and 30 deletions
  1. 29
    30
      app.py

+ 29
- 30
app.py View File

@author: Igor Beloschapkin @author: Igor Beloschapkin
""" """


from tkinter import *
import tkinter.font as tkFont
import tkinter
import subprocess import subprocess
import configparser import configparser


class App: class App:


def __init__(self, master): def __init__(self, master):
self.paradigmText = sys.argv[1]
self.paradigmText = tkinter.sys.argv[1]
# App.paradigmText = sys.argv[1] # App.paradigmText = sys.argv[1]
# pathOrigin = os.path.dirname(os.path.realpath(__file__)) # pathOrigin = os.path.dirname(os.path.realpath(__file__))


textW = 20 textW = 20


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 = tkinter.Button(frame, text=text, bg=bg, command=command)
self.button.config( height = textH, width = textW ) self.button.config( height = textH, width = textW )
self.button['font'] = tkFont.Font(family='Helvetica', size=16, weight='bold')
self.button['font'] = tkinter.font.Font(family='Helvetica', size=16, weight='bold')
self.button.pack(side=side) self.button.pack(side=side)
return self.button return self.button


def makeBtnSmall(self, text, bg, command, side): def makeBtnSmall(self, text, bg, command, side):
self.button = Button(frame, text=text, bg=bg, command=command)
self.button = tkinter.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'] = tkinter.font.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 = tkinter.Frame(master)
frame.pack() frame.pack()


# label generation # label generation
headerText = 'PythonBCIgui V' + str(__version__) + '\n\n' + self.paradigmText + ' BCI' headerText = 'PythonBCIgui V' + str(__version__) + '\n\n' + self.paradigmText + ' BCI'
self.Lparadigm = Label(frame, text = headerText, height = 4, width = 20)
self.Lparadigm['font'] = tkFont.Font(family='Helvetica', size=16, weight='bold')
self.Lparadigm = tkinter.Label(frame, text = headerText, height = 4, width = 20)
self.Lparadigm['font'] = tkinter.font.Font(family='Helvetica', size=16, weight='bold')
self.Lparadigm.pack() self.Lparadigm.pack()


# button generation # button generation
if self.paradigmText == 'Tactile': if self.paradigmText == 'Tactile':
self.Bfilter = makeBtn(self, "1. Filter", "lightyellow", self.btn_filter, TOP)
self.BtacCal = makeBtn(self, "2. Kalibrierung", "lightgreen", self.btn_tacCal, TOP)
self.Bp300 = makeBtn(self, "3. P300 Klassifizierung", "orange", self.btn_p300, TOP)
self.BtacCopy = makeBtn(self, "4. Freies Buchstabieren", "lightblue", self.btn_tacCopy, TOP)
self.BtacSimul = makeBtn(self, "5. Rollstuhlsimulator", "pink", self.btn_tacSimul, TOP)
self.Bfilter = makeBtn(self, "1. Filter", "lightyellow", self.btn_filter, tkinter.TOP)
self.BtacCal = makeBtn(self, "2. Kalibrierung", "lightgreen", self.btn_tacCal, tkinter.TOP)
self.Bp300 = makeBtn(self, "3. P300 Klassifizierung", "orange", self.btn_p300, tkinter.TOP)
self.BtacCopy = makeBtn(self, "4. Freies Buchstabieren", "lightblue", self.btn_tacCopy, tkinter.TOP)
self.BtacSimul = makeBtn(self, "5. Rollstuhlsimulator", "pink", self.btn_tacSimul, tkinter.TOP)
elif self.paradigmText == 'Visual': elif self.paradigmText == 'Visual':
self.Bfilter = makeBtn(self, "1. Filter", "lightyellow", self.btn_filter, TOP)
self.BvisCal = makeBtn(self, "2. Kalibrierung", "lightgreen", self.btn_visCal, TOP)
self.Bp300 = makeBtn(self, "3. P300 Klassifizierung", "orange", self.btn_p300, TOP)
self.BvisCopy = makeBtn(self, "4. Freies Buchstabieren", "lightblue", self.btn_visCopy, TOP)
self.Bfilter = makeBtn(self, "1. Filter", "lightyellow", self.btn_filter, tkinter.TOP)
self.BvisCal = makeBtn(self, "2. Kalibrierung", "lightgreen", self.btn_visCal, tkinter.TOP)
self.Bp300 = makeBtn(self, "3. P300 Klassifizierung", "orange", self.btn_p300, tkinter.TOP)
self.BvisCopy = makeBtn(self, "4. Freies Buchstabieren", "lightblue", self.btn_visCopy, tkinter.TOP)
elif self.paradigmText == 'Test': # TODO Remove elif self.paradigmText == 'Test': # TODO Remove
self.Bfilter = makeBtn(self, "1. Filter", "lightyellow", self.btn_filter, TOP)
self.BvisCal = makeBtn(self, "2. Kalibrierung", "lightgreen", self.btn_visCal, TOP)
self.Bp300 = makeBtn(self, "3. P300 Klassifizierung", "orange", self.btn_p300, TOP)
self.BvisCopy = makeBtn(self, "4. Freies Buchstabieren", "lightblue", self.btn_visCopy, TOP)
self.Btest = makeBtnSmall(self, "TEST", "green", self.btn_test, TOP) # TODO Remove
self.Bfilter = makeBtn(self, "1. Filter", "lightyellow", self.btn_filter, tkinter.TOP)
self.BvisCal = makeBtn(self, "2. Kalibrierung", "lightgreen", self.btn_visCal, tkinter.TOP)
self.Bp300 = makeBtn(self, "3. P300 Klassifizierung", "orange", self.btn_p300, tkinter.TOP)
self.BvisCopy = makeBtn(self, "4. Freies Buchstabieren", "lightblue", self.btn_visCopy, tkinter.TOP)
self.Btest = makeBtnSmall(self, "TEST", "green", self.btn_test, tkinter.TOP) # TODO Remove
else: else:
print('Fehler: Bitte wählen Sie "Tactile" oder "Visual" als Argument') print('Fehler: Bitte wählen Sie "Tactile" oder "Visual" als Argument')
raise ValueError raise ValueError


# self.Bquest = makeBtnSmall(self, "6. Fragebogen", "green", self.btn_quest, TOP) # self.Bquest = makeBtnSmall(self, "6. Fragebogen", "green", self.btn_quest, TOP)
self.BtacConfig = makeBtnSmall(self, "Konfiguration", "gray", self.btn_config, TOP)
self.BtacConfig = makeBtnSmall(self, "Konfiguration", "gray", self.btn_config, tkinter.TOP)


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
# X. Settings ######################### # X. Settings #########################
def btn_config(self): def btn_config(self):
print('Konfiguration') print('Konfiguration')
messagebox.showinfo('Konfiguration', 'Bitte wählen Sie nun den BCI2000 Ordner aus, in dem sich die Ordner "batch", "data", "icons", "parms", "prog" und "tools" befinden.')
config['PATH']['bci2000'] = filedialog.askdirectory()
messagebox.showinfo('Konfiguration', 'Bitte wählen Sie nun den Ordner aus, in dem sich die TactileBCIfilter.exe befindet.')
config['PATH']['tactilebcifilter'] = filedialog.askdirectory()
tkinter.messagebox.showinfo('Konfiguration', 'Bitte wählen Sie nun den BCI2000 Ordner aus, in dem sich die Ordner "batch", "data", "icons", "parms", "prog" und "tools" befinden.')
config['PATH']['bci2000'] = tkinter.filedialog.askdirectory()
tkinter.messagebox.showinfo('Konfiguration', 'Bitte wählen Sie nun den Ordner aus, in dem sich die TactileBCIfilter.exe befindet.')
config['PATH']['tactilebcifilter'] = tkinter.filedialog.askdirectory()
config.write(open('config.ini','w')) config.write(open('config.ini','w'))
# TODO Catch errors falls falsche Ordner gewählt wurden # TODO Catch errors falls falsche Ordner gewählt wurden


window.destroy() window.destroy()


config = configparser.ConfigParser() config = configparser.ConfigParser()
root = Tk()
root = tkinter.Tk()


def on_closing(): def on_closing():
#self.global_close(root) #self.global_close(root)

Loading…
Cancel
Save