Fix tkinter import
This commit is contained in:
parent
88993b84b1
commit
37df6d1884
59
app.py
59
app.py
@ -5,8 +5,7 @@ Created on Fri Sep 4 11:36:24 2020
|
|||||||
@author: Igor Beloschapkin
|
@author: Igor Beloschapkin
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from tkinter import *
|
import tkinter
|
||||||
import tkinter.font as tkFont
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import configparser
|
import configparser
|
||||||
|
|
||||||
@ -20,7 +19,7 @@ __version__ = 0.3
|
|||||||
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__))
|
||||||
|
|
||||||
@ -38,52 +37,52 @@ class App:
|
|||||||
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 = tkinter.Label(frame, text = headerText, height = 4, width = 20)
|
||||||
self.Lparadigm['font'] = tkFont.Font(family='Helvetica', size=16, weight='bold')
|
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.Bfilter = makeBtn(self, "1. Filter", "lightyellow", self.btn_filter, tkinter.TOP)
|
||||||
self.BtacCal = makeBtn(self, "2. Kalibrierung", "lightgreen", self.btn_tacCal, TOP)
|
self.BtacCal = makeBtn(self, "2. Kalibrierung", "lightgreen", self.btn_tacCal, tkinter.TOP)
|
||||||
self.Bp300 = makeBtn(self, "3. P300 Klassifizierung", "orange", self.btn_p300, 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, TOP)
|
self.BtacCopy = makeBtn(self, "4. Freies Buchstabieren", "lightblue", self.btn_tacCopy, tkinter.TOP)
|
||||||
self.BtacSimul = makeBtn(self, "5. Rollstuhlsimulator", "pink", self.btn_tacSimul, 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.Bfilter = makeBtn(self, "1. Filter", "lightyellow", self.btn_filter, tkinter.TOP)
|
||||||
self.BvisCal = makeBtn(self, "2. Kalibrierung", "lightgreen", self.btn_visCal, TOP)
|
self.BvisCal = makeBtn(self, "2. Kalibrierung", "lightgreen", self.btn_visCal, tkinter.TOP)
|
||||||
self.Bp300 = makeBtn(self, "3. P300 Klassifizierung", "orange", self.btn_p300, 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, 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.Bfilter = makeBtn(self, "1. Filter", "lightyellow", self.btn_filter, tkinter.TOP)
|
||||||
self.BvisCal = makeBtn(self, "2. Kalibrierung", "lightgreen", self.btn_visCal, TOP)
|
self.BvisCal = makeBtn(self, "2. Kalibrierung", "lightgreen", self.btn_visCal, tkinter.TOP)
|
||||||
self.Bp300 = makeBtn(self, "3. P300 Klassifizierung", "orange", self.btn_p300, 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, TOP)
|
self.BvisCopy = makeBtn(self, "4. Freies Buchstabieren", "lightblue", self.btn_visCopy, tkinter.TOP)
|
||||||
self.Btest = makeBtnSmall(self, "TEST", "green", self.btn_test, TOP) # TODO Remove
|
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
|
||||||
@ -155,10 +154,10 @@ class App:
|
|||||||
# 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.')
|
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'] = filedialog.askdirectory()
|
config['PATH']['bci2000'] = tkinter.filedialog.askdirectory()
|
||||||
messagebox.showinfo('Konfiguration', 'Bitte wählen Sie nun den Ordner aus, in dem sich die TactileBCIfilter.exe befindet.')
|
tkinter.messagebox.showinfo('Konfiguration', 'Bitte wählen Sie nun den Ordner aus, in dem sich die TactileBCIfilter.exe befindet.')
|
||||||
config['PATH']['tactilebcifilter'] = filedialog.askdirectory()
|
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
|
||||||
|
|
||||||
@ -171,7 +170,7 @@ class App:
|
|||||||
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…
x
Reference in New Issue
Block a user