Page_2.py 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. import tkinter as tk
  2. import tk_tools
  3. import numpy as np
  4. from datetime import datetime
  5. from .Plot import Plot
  6. from .globals import *
  7. class Page_2(tk.Frame):
  8. plotLen = 100
  9. def __init__(self, parent, controller):
  10. tk.Frame.__init__(self, parent)
  11. self.controller = controller
  12. label = tk.Label(self, text="Kräfte", font=LARGE_FONT)
  13. label.pack(pady=10,padx=10)
  14. # graphs
  15. self.forcePlot = Plot(xaxis=(-2, 2), yaxis=(-2, 2),
  16. ytitle="y-Kraft [mV]",
  17. xtitle="x-Kraft [mV]",
  18. title="XY-Graph",
  19. line_colors=["#2222ff", "#22ff22", "#ff2222", "#000000"])
  20. canvas = self.forcePlot.create_canvas(self)
  21. canvas.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
  22. def update(self, visible):
  23. if visible:
  24. self.forcePlot.plot_data(
  25. xs=[self.controller.getLastValues(self.plotLen, "force_X_{}".format(i+1)) for i in range(3)] +
  26. [np.sin(np.linspace(0, 6.282, self.plotLen))],
  27. ys=[self.controller.getLastValues(self.plotLen, "force_Y_{}".format(i+1)) for i in range(3)] +
  28. [np.cos(np.linspace(0, 6.282, self.plotLen))]
  29. )