Page_4.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. from .globals import *
  8. class Page_4(tk.Frame):
  9. def __init__(self, parent, controller):
  10. tk.Frame.__init__(self, parent)
  11. self.controller = controller
  12. frame = tk.LabelFrame(self, text="Einstellungen")
  13. frame.pack(side=tk.LEFT, fill=tk.BOTH)
  14. tk.Label(frame, text="Aktualisierungsinterval in ms").pack(padx=5, pady=5)
  15. self.intervalSlider = tk.Scale(frame, from_=50, to=1000, resolution=10, orient=tk.HORIZONTAL)
  16. self.intervalSlider.set(300)
  17. self.intervalSlider.pack(side="top", fill="both", padx=5, pady=5)
  18. tk.Label(frame, text="PID-Interval in ms").pack(padx=5, pady=5)
  19. self.pidSlider = tk.Scale(frame, from_=5, to=500, resolution=1, orient=tk.HORIZONTAL)
  20. self.pidSlider.set(100)
  21. self.pidSlider.pack(side="top", fill="both", padx=5, pady=5)
  22. gridFrame = tk.LabelFrame(self, text="System Check")
  23. gridFrame.pack(side=tk.LEFT, fill=tk.BOTH)
  24. tk.Label(gridFrame, padx=5, pady=5, text="{:32s}".format("Messwerte")).grid(row=0, column=0)
  25. self.rowCountLabel = tk.Label(gridFrame, padx=5, pady=5, text="")
  26. self.rowCountLabel.grid(row=0, column=1)
  27. self.sysLabels = []
  28. for i in range(1, len(self.controller.columnNames)):
  29. name = controller.columnNames[i]
  30. la = tk.Label(gridFrame, fg='red', padx=5, pady=5, text="{:32s}".format(name))
  31. la.grid(row=i, column=0)
  32. lb = tk.Label(gridFrame, fg='red', padx=5, pady=5, text="")
  33. lb.grid(row=i, column=1)
  34. self.sysLabels.append((la, lb))
  35. def update(self, visible):
  36. if visible:
  37. self.controller.intervalDelay = self.intervalSlider.get()
  38. self.controller.pidDelay = self.pidSlider.get()
  39. row = self.controller.getLastRows(1)[0]
  40. for i in range(len(row)):
  41. nameLabel, valueLabel = self.sysLabels[i]
  42. color = 'red' if np.isnan(row[i]) else 'black' if row[i] == 0 else 'green'
  43. nameLabel.config( fg = color)
  44. valueLabel.config(fg = color, text="{:5.4f}".format(row[i]))
  45. self.rowCountLabel.config(text="{:d} / {:d}".format(min(self.controller.rowIndex, self.controller.nRows), self.controller.nRows))