Datenablage für Tinnitus Therapie Projektarbeit von Julian Seyffer und Heiko Ommert SS2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TinnitusAnalyse_GUI.py 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. from tkinter import * # all the classic tkinter stuff
  2. from tkinter import ttk # some newer additional widgets
  3. """
  4. Background Funktionen
  5. """
  6. def button_rauschen_minus_press():
  7. print("Rauschen_Press_Plus pressed")
  8. def button_rauschen_plus_press():
  9. print("Rauschen Press_Minus pressed")
  10. # Ohr (links/beide/rechts)
  11. def button_linkes_ohr_press():
  12. print("button linkes ohr pressed")
  13. def button_beide_ohren_press():
  14. print("button beide ohren pressed")
  15. def button_rechtes_ohr_press():
  16. print("button rechtes ohr pressed")
  17. # Lautstärke
  18. def scale_lautstärke_change(self):
  19. lautstärke = float(scaleLautstärke.get())
  20. print(lautstärke)
  21. root = Tk() # build the main window
  22. root.title("Tinnitus Analyse")
  23. # MainFrame
  24. mainFrame = ttk.Frame(root, padding="3 3 30 30") # parent is root, padding is extra space at the edges
  25. mainFrame.grid(column=0, row=0, sticky=(N, W, E, S)) # the frame sticks to every side of the window when resized
  26. # Frequenz
  27. labelFrequenz = Label(mainFrame, text="Frequenz [kHz]")
  28. labelFrequenz.grid(row=0, column=0, sticky="w") # sticky = w(est) makes the text left aligned
  29. frequenz = StringVar() # Frequenz Variable [kHz]
  30. entryFrequenz = ttk.Entry(mainFrame, width=7, textvariable=frequenz) # create a field where u can enter text
  31. entryFrequenz.grid(column=1, row=0, sticky=(W, E)) # position the field
  32. # todo: Failproof the entry field to just numbers between a range!
  33. # todo: add function to entry change!
  34. # Rauschen
  35. labelRauschen = Label(mainFrame, text="Rauschen [+/- kHz]", anchor="w")
  36. labelRauschen.grid(column=0, row=1, sticky="w")
  37. buttonRauschenPlus = Button(mainFrame, text="+", command=button_rauschen_plus_press)
  38. buttonRauschenPlus.grid(column=1, row=1)
  39. buttonRauschenMinus = Button(mainFrame, text="-", command=button_rauschen_minus_press)
  40. buttonRauschenMinus.grid(column=2, row=1)
  41. rauschen = StringVar() # Rauschen Variable [+/- kHz]
  42. entryRauschen = ttk.Entry(mainFrame, width=7, textvariable=rauschen) # create a field where u can enter text
  43. entryRauschen.grid(column=3, row=1) # position the field
  44. # todo: add function to entry change
  45. # Linkes / Rechts Ohr
  46. labelOhren = Label(mainFrame, text="Audioausgabe auf:")
  47. labelOhren.grid(column=0, row=2, sticky="w")
  48. buttonLinkesOhr = Button(mainFrame, text="linkem Ohr", command=button_linkes_ohr_press)
  49. buttonLinkesOhr.grid(column=1, row=2)
  50. buttonBeideOhren = Button(mainFrame, text="beiden Ohren", command=button_beide_ohren_press)
  51. buttonBeideOhren.grid(column=2, row=2)
  52. buttonRechtesOhr = Button(mainFrame, text="rechtem Ohr", command=button_rechtes_ohr_press)
  53. buttonRechtesOhr.grid(column=3, row=2)
  54. # Lautstärke
  55. labelLautstärke = Label(mainFrame, text="Lautstärke [%]:")
  56. labelLautstärke.grid(column=0, row=3)
  57. scaleLautstärke = Scale(mainFrame, from_=0, to=100, orient=HORIZONTAL, length=200, command=scale_lautstärke_change)
  58. scaleLautstärke.grid(column=1, row=3, columnspan=2)
  59. # --------------EXAMPLE GUI----------------------
  60. # mainframe = ttk.Frame(root, padding="3 3 3 3") # parent is root, padding is extra space at the edges
  61. # mainframe.grid(column=0, row=0, sticky=(N, W, E, S)) # the frame sticks to every side of the window when resized
  62. # root.columnconfigure(0, weight=1) # if the main window is resized, the frame should expand to take up the extra space
  63. # root.rowconfigure(0, weight=1) # if the main window is resized, the frame should expand to take up the extra space
  64. #
  65. # frequency = StringVar() # a StringVar is meant to be used to edit Tkinter widget's texts
  66. # meters = StringVar()
  67. #
  68. # """
  69. # Frequency Entry
  70. # """
  71. # frequency_entry = ttk.Entry(mainframe, width=7, textvariable=frequency) # create a field where u can enter text
  72. # frequency_entry.grid(column=2, row=1, sticky=(W, E)) # position the field
  73. # ttk.Label(mainframe, text="Frequenz (kHz)").grid(column=1, row=1, sticky=W) # label the field
  74. #
  75. # """
  76. # Rauschen
  77. # """
  78. # frequency_entry = ttk.Entry(mainframe, width=7, textvariable=frequency) # create a field where u can enter text
  79. # frequency_entry.grid(column=2, row=1, sticky=(W, E)) # position the field
  80. # ttk.Label(mainframe, text="frequency (kHz)").grid(column=1, row=1, sticky=W) # label the field
  81. #
  82. # ttk.Label(mainframe, textvariable=meters).grid(column=2, row=2, sticky=(W, E))
  83. # ttk.Button(mainframe, text="Calculate", command=calculate).grid(column=3, row=3, sticky=W)
  84. #
  85. # #ttk.Label(mainframe, text="frequency (kHz)").grid(column=3, row=1, sticky=W)
  86. # ttk.Label(mainframe, text="is equivalent to").grid(column=1, row=2, sticky=E)
  87. # ttk.Label(mainframe, text="meters").grid(column=3, row=2, sticky=W)
  88. #
  89. # for child in mainframe.winfo_children(): child.grid_configure(padx=5, pady=5)
  90. #
  91. # frequency_entry.focus()
  92. # root.bind('<Return>', calculate)
  93. root.mainloop()