appWindow.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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.spd610Array import Spd610Array
  5. from wirelessLoadCell.loadCells import LoadCells
  6. from ui import *
  7. import matplotlib
  8. from matplotlib.backends.backend_tkagg import (
  9. FigureCanvasTkAgg, NavigationToolbar2Tk)
  10. from matplotlib.figure import Figure
  11. import matplotlib.animation as animation
  12. from matplotlib import style
  13. import tkinter as tk
  14. import tk_tools
  15. from time import *
  16. LARGE_FONT= ("Verdana", 12)
  17. style.use("ggplot")
  18. class Main(tk.Tk):
  19. def __init__(self, *args, **kwargs):
  20. tk.Tk.__init__(self, *args, **kwargs)
  21. tk.Tk.wm_title(self, "Windkanal-Tool")
  22. container = tk.Frame(self)
  23. container.pack(side="top", fill="both", expand = True)
  24. container.grid_rowconfigure(0, weight=1)
  25. container.grid_columnconfigure(0, weight=1)
  26. menubar = tk.Menu(container)
  27. filemenu = tk.Menu(menubar, tearoff=0)
  28. filemenu.add_command(label="Save settings", command = lambda: self.popupmsg("Not supported just yet!"))
  29. filemenu.add_separator()
  30. filemenu.add_command(label="Exit", command=quit)
  31. menubar.add_cascade(label="File", menu=filemenu)
  32. tk.Tk.config(self, menu=menubar)
  33. self.frames = {}
  34. for F in (Page_1, Page_2, Page_3, Page_4):
  35. frame = F(container, self)
  36. self.frames[F] = frame
  37. frame.grid(row=0, column=0, sticky="nsew")
  38. self.show_frame(Page_1)
  39. def show_frame(self, cont):
  40. frame = self.frames[cont]
  41. frame.tkraise()
  42. def popupmsg(self, msg=""):
  43. popup = tk.Toplevel(self.master)
  44. popup.wm_title("Error!")
  45. label = tk.Label(popup, text=msg, font=LARGE_FONT)
  46. label.pack(side="top", fill="x", pady=10)
  47. b1 = tk.Button(popup, text="Okay", command=popup.destroy)
  48. b1.pack()
  49. def interval(self):
  50. for frame in self.frames:
  51. frame.update()
  52. self.after(300,self.interval)