Page_1.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import tkinter as tk
  2. import tk_tools
  3. from .Plot import Plot
  4. from .globals import *
  5. import matplotlib
  6. from matplotlib.backends.backend_tkagg import (
  7. FigureCanvasTkAgg, NavigationToolbar2Tk)
  8. from matplotlib.figure import Figure
  9. from matplotlib import style
  10. class Page_1(tk.Frame):
  11. def __init__(self, parent, controller):
  12. tk.Frame.__init__(self, parent)
  13. self.t = 0
  14. self.controller = controller
  15. # graph
  16. self.serialPlot = Plot(20)
  17. canvas = FigureCanvasTkAgg(self.serialPlot.fig, self)
  18. canvas.draw()
  19. canvas.get_tk_widget().pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
  20. canvas._tkcanvas.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
  21. # right menu
  22. left = tk.Frame(self, borderwidth=2, relief="solid")
  23. container = tk.Frame(left, borderwidth=2, relief="solid")
  24. label1 = tk.Label(container, text="I could be a canvas, but I'm a label right now")
  25. self.label4 = tk.Label(self,font=("Arial","30"),fg="red")
  26. self.label4.pack()
  27. self.label4.config(text=str(self.t))
  28. SendButton = tk.Button(left, text='Quit', command=quit)
  29. label2 = tk.Label(left, text="I could be a button")
  30. label3 = tk.Label(left, text="So could I")
  31. left.pack(side="left", expand=True, fill="both")
  32. container.pack(expand=True, fill="both", padx=7, pady=5)
  33. SendButton.pack()
  34. label1.pack()
  35. label2.pack()
  36. label3.pack()
  37. controller.pid.SetPoint = 0.4 # m/s
  38. def update(self):
  39. self.serialPlot.update(self.controller.getLastValue("force_X_1"))
  40. self.label4.config(text="{:3d} Nm".format(3))