Browse Source

Fix tkinter import

master
Igor Beloschapkin 4 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

@@ -5,8 +5,7 @@ Created on Fri Sep 4 11:36:24 2020
@author: Igor Beloschapkin
"""

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

@@ -20,7 +19,7 @@ __version__ = 0.3
class App:

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

@@ -38,52 +37,52 @@ class App:
textW = 20

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['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)
return self.button

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['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)
return self.button

frame = Frame(master)
frame = tkinter.Frame(master)
frame.pack()

# label generation
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()

# button generation
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':
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
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:
print('Fehler: Bitte wählen Sie "Tactile" oder "Visual" als Argument')
raise ValueError

# 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.columnconfigure((0,2), weight=1) # when window is resized
@@ -155,10 +154,10 @@ class App:
# X. Settings #########################
def btn_config(self):
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'))
# TODO Catch errors falls falsche Ordner gewählt wurden

@@ -171,7 +170,7 @@ class App:
window.destroy()

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

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

Loading…
Cancel
Save