Page_1.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. # graph
  15. self.serialPlot = Plot(20)
  16. canvas = FigureCanvasTkAgg(self.serialPlot.fig, self)
  17. canvas.draw()
  18. canvas.get_tk_widget().pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
  19. canvas._tkcanvas.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
  20. # right menu
  21. left = tk.Frame(self, borderwidth=2, relief="solid")
  22. container = tk.Frame(left, borderwidth=2, relief="solid")
  23. label1 = tk.Label(container, text="I could be a canvas, but I'm a label right now")
  24. self.label4 = tk.Label(self,font=("Arial","30"),fg="red")
  25. self.label4.pack()
  26. self.label4.config(text=str(self.t))
  27. SendButton = tk.Button(left, text='Quit', command=quit)
  28. label2 = tk.Label(left, text="I could be a button")
  29. label3 = tk.Label(left, text="So could I")
  30. left.pack(side="left", expand=True, fill="both")
  31. container.pack(expand=True, fill="both", padx=7, pady=5)
  32. SendButton.pack()
  33. label1.pack()
  34. label2.pack()
  35. label3.pack()
  36. def update(self):
  37. self.serialPlot.update(3)
  38. self.label4.config(text="{:3d} Nm".format(3))