|
|
@@ -1,12 +1,7 @@ |
|
|
|
from tkinter import * # all the classic tkinter stuff |
|
|
|
from tkinter import ttk # some newer additional widgets |
|
|
|
|
|
|
|
""" |
|
|
|
Background Funktionen |
|
|
|
""" |
|
|
|
|
|
|
|
|
|
|
|
from tkinter.ttk import Frame, Label, Button, LabelFrame, Combobox, Style, Checkbutton, Entry, Panedwindow |
|
|
|
|
|
|
|
# FUNKTIONEN DIE DURCH GUI KLICKS AUSGEFÜHRT WERDEN--------------------------------------------------------------------- |
|
|
|
|
|
|
|
def button_rauschen_minus_press(): |
|
|
|
print("Rauschen_Press_Plus pressed") |
|
|
@@ -20,9 +15,11 @@ def button_rauschen_plus_press(): |
|
|
|
def button_linkes_ohr_press(): |
|
|
|
print("button linkes ohr pressed") |
|
|
|
|
|
|
|
|
|
|
|
def button_beide_ohren_press(): |
|
|
|
print("button beide ohren pressed") |
|
|
|
|
|
|
|
|
|
|
|
def button_rechtes_ohr_press(): |
|
|
|
print("button rechtes ohr pressed") |
|
|
|
|
|
|
@@ -32,94 +29,108 @@ def scale_lautstärke_change(self): |
|
|
|
lautstärke = float(scaleLautstärke.get()) |
|
|
|
print(lautstärke) |
|
|
|
|
|
|
|
root = Tk() # build the main window |
|
|
|
root.title("Tinnitus Analyse") |
|
|
|
|
|
|
|
# MainFrame |
|
|
|
mainFrame = ttk.Frame(root, padding="3 3 30 30") # parent is root, padding is extra space at the edges |
|
|
|
mainFrame.grid(column=0, row=0, sticky=(N, W, E, S)) # the frame sticks to every side of the window when resized |
|
|
|
|
|
|
|
# Frequenz |
|
|
|
labelFrequenz = Label(mainFrame, text="Frequenz [kHz]") |
|
|
|
labelFrequenz.grid(row=0, column=0, sticky="w") # sticky = w(est) makes the text left aligned |
|
|
|
|
|
|
|
frequenz = StringVar() # Frequenz Variable [kHz] |
|
|
|
entryFrequenz = ttk.Entry(mainFrame, width=7, textvariable=frequenz) # create a field where u can enter text |
|
|
|
entryFrequenz.grid(column=1, row=0, sticky=(W, E)) # position the field |
|
|
|
# todo: Failproof the entry field to just numbers between a range! |
|
|
|
# todo: add function to entry change! |
|
|
|
def button_ohren_synchro(): |
|
|
|
auswahl = comboOhrenSynchro.get() # holt die momentane Auswahl aus combobox |
|
|
|
print("Einstellungen von:" + auswahl + " auf alle anderen Ohren setzen") |
|
|
|
|
|
|
|
# Rauschen |
|
|
|
labelRauschen = Label(mainFrame, text="Rauschen [+/- kHz]", anchor="w") |
|
|
|
labelRauschen.grid(column=0, row=1, sticky="w") |
|
|
|
|
|
|
|
buttonRauschenPlus = Button(mainFrame, text="+", command=button_rauschen_plus_press) |
|
|
|
buttonRauschenPlus.grid(column=1, row=1) |
|
|
|
|
|
|
|
buttonRauschenMinus = Button(mainFrame, text="-", command=button_rauschen_minus_press) |
|
|
|
buttonRauschenMinus.grid(column=2, row=1) |
|
|
|
|
|
|
|
rauschen = StringVar() # Rauschen Variable [+/- kHz] |
|
|
|
entryRauschen = ttk.Entry(mainFrame, width=7, textvariable=rauschen) # create a field where u can enter text |
|
|
|
entryRauschen.grid(column=3, row=1) # position the field |
|
|
|
# todo: add function to entry change |
|
|
|
|
|
|
|
# Linkes / Rechts Ohr |
|
|
|
labelOhren = Label(mainFrame, text="Audioausgabe auf:") |
|
|
|
labelOhren.grid(column=0, row=2, sticky="w") |
|
|
|
|
|
|
|
buttonLinkesOhr = Button(mainFrame, text="linkem Ohr", command=button_linkes_ohr_press) |
|
|
|
buttonLinkesOhr.grid(column=1, row=2) |
|
|
|
|
|
|
|
buttonBeideOhren = Button(mainFrame, text="beiden Ohren", command=button_beide_ohren_press) |
|
|
|
buttonBeideOhren.grid(column=2, row=2) |
|
|
|
|
|
|
|
buttonRechtesOhr = Button(mainFrame, text="rechtem Ohr", command=button_rechtes_ohr_press) |
|
|
|
buttonRechtesOhr.grid(column=3, row=2) |
|
|
|
|
|
|
|
# Lautstärke |
|
|
|
labelLautstärke = Label(mainFrame, text="Lautstärke [%]:") |
|
|
|
labelLautstärke.grid(column=0, row=3) |
|
|
|
|
|
|
|
scaleLautstärke = Scale(mainFrame, from_=0, to=100, orient=HORIZONTAL, length=200, command=scale_lautstärke_change) |
|
|
|
scaleLautstärke.grid(column=1, row=3, columnspan=2) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# --------------EXAMPLE GUI---------------------- |
|
|
|
# mainframe = ttk.Frame(root, padding="3 3 3 3") # parent is root, padding is extra space at the edges |
|
|
|
# mainframe.grid(column=0, row=0, sticky=(N, W, E, S)) # the frame sticks to every side of the window when resized |
|
|
|
# root.columnconfigure(0, weight=1) # if the main window is resized, the frame should expand to take up the extra space |
|
|
|
# root.rowconfigure(0, weight=1) # if the main window is resized, the frame should expand to take up the extra space |
|
|
|
# |
|
|
|
# frequency = StringVar() # a StringVar is meant to be used to edit Tkinter widget's texts |
|
|
|
# meters = StringVar() |
|
|
|
# |
|
|
|
# """ |
|
|
|
# Frequency Entry |
|
|
|
# """ |
|
|
|
# frequency_entry = ttk.Entry(mainframe, width=7, textvariable=frequency) # create a field where u can enter text |
|
|
|
# frequency_entry.grid(column=2, row=1, sticky=(W, E)) # position the field |
|
|
|
# ttk.Label(mainframe, text="Frequenz (kHz)").grid(column=1, row=1, sticky=W) # label the field |
|
|
|
# |
|
|
|
# """ |
|
|
|
# Rauschen |
|
|
|
# """ |
|
|
|
# frequency_entry = ttk.Entry(mainframe, width=7, textvariable=frequency) # create a field where u can enter text |
|
|
|
# frequency_entry.grid(column=2, row=1, sticky=(W, E)) # position the field |
|
|
|
# ttk.Label(mainframe, text="frequency (kHz)").grid(column=1, row=1, sticky=W) # label the field |
|
|
|
# |
|
|
|
# ttk.Label(mainframe, textvariable=meters).grid(column=2, row=2, sticky=(W, E)) |
|
|
|
# ttk.Button(mainframe, text="Calculate", command=calculate).grid(column=3, row=3, sticky=W) |
|
|
|
# |
|
|
|
# #ttk.Label(mainframe, text="frequency (kHz)").grid(column=3, row=1, sticky=W) |
|
|
|
# ttk.Label(mainframe, text="is equivalent to").grid(column=1, row=2, sticky=E) |
|
|
|
# ttk.Label(mainframe, text="meters").grid(column=3, row=2, sticky=W) |
|
|
|
# |
|
|
|
# for child in mainframe.winfo_children(): child.grid_configure(padx=5, pady=5) |
|
|
|
# |
|
|
|
# frequency_entry.focus() |
|
|
|
# root.bind('<Return>', calculate) |
|
|
|
|
|
|
|
root.mainloop() |
|
|
|
# AUFBAU DES ROOT WINDOWS ---------------------------------------------------------------------------------------------- |
|
|
|
root = Tk() # build the main window |
|
|
|
root.title("Tinnitus Analyse") |
|
|
|
#root.iconbitmap('headphones.ico') #todo: fix icon |
|
|
|
root.minsize(width=800, height=600) |
|
|
|
root.resizable(True, True) |
|
|
|
#root.columnconfigure(0, weight=1) |
|
|
|
root.rowconfigure(0, weight=1) # extra platz nach unten wird automatisch von Frames eingenommen |
|
|
|
|
|
|
|
|
|
|
|
# DIE DREI OBEREN FRAMES AUFBAUEN--------------------------------------------------------------------------------------- |
|
|
|
linkerFrame = LabelFrame(root, text="linkes Ohr", width=100, height = 100, padding="3 3 30 30") # parent is root, padding is extra space at the edges |
|
|
|
linkerFrame.grid(column=0, row=0, sticky=(N + W + E + S)) # the frame sticks to every side of the window when resized |
|
|
|
|
|
|
|
mittlererFrame = LabelFrame(root, text="beide Ohren", width=100, height=100, padding="3 3 30 30") |
|
|
|
mittlererFrame.grid(column=1, row=0, sticky=(N + W + E + S)) |
|
|
|
|
|
|
|
rechterFrame = LabelFrame(root, text="rechtes Ohr", width=100, height=100, padding="3 3 30 30") |
|
|
|
rechterFrame.grid(column=2, row=0, sticky=(N + W + E + S)) |
|
|
|
|
|
|
|
|
|
|
|
# DIE DREI OBEREN FRAMES FÜLLEN----------------------------------------------------------------------------------------- |
|
|
|
labelFrames = [linkerFrame, mittlererFrame, rechterFrame] |
|
|
|
for aktLabelFrame in labelFrames: |
|
|
|
# -------- FREQUENZ ------------------------ |
|
|
|
labelFrequenz = Label(aktLabelFrame, text="Frequenz [kHz]") |
|
|
|
labelFrequenz.grid(row=0, column=0, sticky=W) # sticky = w(est) makes the text left aligned |
|
|
|
frequenz = DoubleVar() # Frequenz Variable [kHz] |
|
|
|
entryFrequenz = Entry(aktLabelFrame, textvariable=frequenz) # create a field where u can enter text |
|
|
|
entryFrequenz.grid(column=1, row=0, sticky=W) # position the field |
|
|
|
# todo: Failproof the entry field to just numbers between a range! |
|
|
|
# todo: add function to entry change! |
|
|
|
# ----------- RAUSCHEN -------------------- |
|
|
|
# todo: iwas überlegen ich brauch 3 verschiedene stringVars eigentlich für jedes Ohr!!! |
|
|
|
# todo: add function to entry change |
|
|
|
labelRauschen = Label(aktLabelFrame, text="Rauschen[+/- kHz]", anchor="w") |
|
|
|
labelRauschen.grid(column=0, row=1, sticky=W) |
|
|
|
buttonRauschenPlus = Button(aktLabelFrame, text="+", command=button_rauschen_plus_press) |
|
|
|
buttonRauschenPlus.grid(column=2, row=1) |
|
|
|
buttonRauschenMinus = Button(aktLabelFrame, text="-", command=button_rauschen_minus_press) |
|
|
|
buttonRauschenMinus.grid(column=3, row=1) |
|
|
|
rauschen = StringVar() # Rauschen Variable [+/- kHz] |
|
|
|
entryRauschen = Entry(aktLabelFrame, textvariable=rauschen) # create a field where u can enter text |
|
|
|
entryRauschen.grid(column=1, row=1, sticky=W) # position the field |
|
|
|
# ------------------ LAUTSTÄRKE ------------------ |
|
|
|
labelLautstärke = Label(aktLabelFrame, text="Lautstärke [%]:") |
|
|
|
labelLautstärke.grid(column=0, row=3, sticky="w") |
|
|
|
scaleLautstärke = Scale(aktLabelFrame, from_=0, to=100, orient=HORIZONTAL, length=200, command=scale_lautstärke_change) |
|
|
|
scaleLautstärke.grid(column=1, row=3, columnspan=2) |
|
|
|
# ------------ KOMMENTAR ---------------- |
|
|
|
labelKommentar = Label(aktLabelFrame, text="weitere Kommentare:") |
|
|
|
labelKommentar.grid(column=0, row=4) |
|
|
|
kommentar = StringVar() # Rauschen Variable [+/- kHz] |
|
|
|
entryKommentar = Entry(aktLabelFrame, textvariable=kommentar, width=33) # create a field where u can enter text |
|
|
|
entryKommentar.grid(column=1, row=4, rowspan=4, columnspan=2, sticky=W) |
|
|
|
|
|
|
|
|
|
|
|
# DEN UNTEREN FRAME BAUEN----------------------------------------------------------------------------------------------- |
|
|
|
untererFrame = LabelFrame(root, text="Generelles", width=300, height=100, padding="3 3 30 30") |
|
|
|
untererFrame.grid(column=0, row=1, columnspan=3, sticky=(N + W + E + S)) |
|
|
|
|
|
|
|
# DEN UNTEREN FRAME FÜLLEN---------------------------------------------------------------------------------------------- |
|
|
|
# ------------NAMENSEINGABE------------- |
|
|
|
labelNachname = Label(untererFrame, text="Nachname:") |
|
|
|
labelNachname.grid(column=0, row=0) |
|
|
|
nachname = StringVar() |
|
|
|
entryNachname = Entry(untererFrame, textvariable=nachname) |
|
|
|
entryNachname.grid(column=1, row=0) |
|
|
|
labelVorname = Label(untererFrame, text="Vorname:") |
|
|
|
labelVorname.grid(column=2, row=0) |
|
|
|
vorname = StringVar() |
|
|
|
entryVorname = Entry(untererFrame, textvariable=vorname) |
|
|
|
entryVorname.grid(column=3, row=0) |
|
|
|
# ------------------OHRENAUSWAHL----------- |
|
|
|
labelOhren = Label(untererFrame, text="Audioausgabe auf:") |
|
|
|
labelOhren.grid(column=0, row=1, sticky="w") |
|
|
|
buttonLinkesOhr = Button(untererFrame, text="linkem Ohr", command=button_linkes_ohr_press) |
|
|
|
buttonLinkesOhr.grid(column=1, row=1) |
|
|
|
buttonBeideOhren = Button(untererFrame, text="beiden Ohren", command=button_beide_ohren_press) |
|
|
|
buttonBeideOhren.grid(column=2, row=1) |
|
|
|
buttonRechtesOhr = Button(untererFrame, text="rechtem Ohr", command=button_rechtes_ohr_press) |
|
|
|
buttonRechtesOhr.grid(column=3, row=1) |
|
|
|
# --------- OHREN SYNCHRONISIEREN ----------------------- |
|
|
|
labelOhrenSynchro = Label(untererFrame, text="Einstellungen von ") |
|
|
|
labelOhrenSynchro.grid(column=0, row=2) |
|
|
|
comboOhrenSynchro = Combobox(untererFrame, values=["Linkes Ohr", "Rechtes Ohr", "Beide Ohren"]) |
|
|
|
comboOhrenSynchro.grid(column=1, row=2) |
|
|
|
labelOhrenSynchro2 = Label(untererFrame, text=" für alle anderen Ohren übernehmen") |
|
|
|
labelOhrenSynchro2.grid(column=2, row=2) |
|
|
|
buttonOhrenSynchro = Button(untererFrame, text="Bestätigen", command=button_ohren_synchro) |
|
|
|
buttonOhrenSynchro.grid(column=3, row=2) |
|
|
|
|
|
|
|
# ----------- SPEICHERN -------------------- |
|
|
|
buttonSpeichern = Button(untererFrame, text="SPEICHERN") |
|
|
|
buttonSpeichern.grid(column=6, row=3) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
root.mainloop() |