appWindow.py 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. # The code for changing pages was derived from: http://stackoverflow.com/questions/7546050/switch-between-two-frames-in-tkinter
  2. # License: http://creativecommons.org/licenses/by-sa/3.0/
  3. from analogPressure.sdpArray import SdpArray
  4. from digitalPressure.sdp610Array import Spd610Array
  5. from wirelessLoadCell.loadCells import LoadCells
  6. from ui import *
  7. import tkinter as tk
  8. import tk_tools
  9. from time import *
  10. class Main(tk.Tk):
  11. def __init__(self, *args, **kwargs):
  12. tk.Tk.__init__(self, *args, **kwargs)
  13. tk.Tk.wm_title(self, "Windkanal-Tool")
  14. container = tk.Frame(self)
  15. container.pack(side="top", fill="both", expand = True)
  16. container.grid_rowconfigure(0, weight=1)
  17. container.grid_columnconfigure(0, weight=1)
  18. menubar = tk.Menu(container)
  19. filemenu = tk.Menu(menubar, tearoff=0)
  20. filemenu.add_command(label="Save settings", command = lambda: self.popupmsg("Not supported just yet!"))
  21. filemenu.add_separator()
  22. filemenu.add_command(label="Exit", command=quit)
  23. menubar.add_cascade(label="File", menu=filemenu)
  24. tk.Tk.config(self, menu=menubar)
  25. label = tk.Label(self, text="Bedienelemente", font=LARGE_FONT)
  26. label.pack(pady=10,padx=10)
  27. # top menu
  28. top = tk.Frame(self, borderwidth=2, relief="solid")
  29. button1 = tk.Button(top, text="Bedienelemente", command=lambda: self.show_frame(Page_1))
  30. button1.pack(side=tk.LEFT)
  31. button2 = tk.Button(top, text="Kräfte", command=lambda: self.show_frame(Page_2))
  32. button2.pack(side=tk.LEFT)
  33. button3 = tk.Button(top, text="Druck", command=lambda: self.show_frame(Page_3))
  34. button3.pack(side=tk.LEFT)
  35. button4 = tk.Button(top,text="Einstellungen",command=lambda: self.show_frame(Page_4))
  36. button4.pack(side=tk.LEFT)
  37. button5 = tk.Button(top, text="QUIT", fg="red",command=quit)
  38. button5.pack(side=tk.LEFT)
  39. top.pack(side="top", expand=True, fill="both")
  40. self.frames = {}
  41. for F in (Page_1, Page_2, Page_3, Page_4):
  42. frame = F(container, self)
  43. self.frames[F] = frame
  44. frame.grid(row=0, column=0, sticky="nsew")
  45. self.show_frame(Page_1)
  46. def show_frame(self, cont):
  47. frame = self.frames[cont]
  48. frame.tkraise()
  49. def popupmsg(self, msg=""):
  50. popup = tk.Toplevel(self.master)
  51. popup.wm_title("Error!")
  52. label = tk.Label(popup, text=msg, font=LARGE_FONT)
  53. label.pack(side="top", fill="x", pady=10)
  54. b1 = tk.Button(popup, text="Okay", command=popup.destroy)
  55. b1.pack()
  56. def interval(self):
  57. for frame in self.frames:
  58. frame.update()
  59. self.after(300,self.interval)