Page_1.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import tkinter as tk
  2. import tk_tools
  3. import time
  4. from .Plot import Plot
  5. from .globals import *
  6. class Page_1(tk.Frame):
  7. def __init__(self, parent, controller):
  8. tk.Frame.__init__(self, parent)
  9. self.t = 0
  10. self.controller = controller
  11. # graph
  12. self.serialPlot = Plot(nPoints=100, xaxis=(0, 100), yaxis=(0, 5), nGraphs=2,
  13. ytitle="Windgeschwindigkeit m/s",
  14. xtitle="Messpunkte [1/3-Sekunde]",
  15. title="Geschwindigkeitsverlauf",
  16. line_colors=["#2222ff", "#22ff22", "#ff2222"])
  17. canvas = self.serialPlot.create_canvas(self)
  18. canvas.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
  19. # right menu
  20. left = tk.Frame(self, borderwidth=2, relief="solid")
  21. container = tk.Frame(left, borderwidth=2, relief="solid")
  22. label1 = tk.Label(container, text="I could be a canvas, but I'm a label right now")
  23. self.label4 = tk.Label(self,font=("Arial","30"),fg="red")
  24. self.label4.pack()
  25. self.label4.config(text=str(self.t))
  26. SendButton = tk.Button(left, text='Quit', command=quit)
  27. label2 = tk.Label(left, text="I could be a button")
  28. label3 = tk.Label(left, text="So could I")
  29. left.pack(side="left", expand=True, fill="both")
  30. container.pack(expand=True, fill="both", padx=7, pady=5)
  31. SendButton.pack()
  32. label1.pack()
  33. label2.pack()
  34. label3.pack()
  35. controller.pid.SetPoint = 0.4 # m/s
  36. def update(self, visible):
  37. self.serialPlot.update([self.controller.getLastValue("adc_0"), (time.time()/0.3) % 1 * 5], visible=visible)
  38. if visible:
  39. self.label4.config(text="{:5.3f} V".format(self.controller.getLastValue("adc_0")))