Page_4.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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()
  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. gridFrame = tk.LabelFrame(self, text="System Check")
  19. gridFrame.pack(side=tk.LEFT, fill=tk.BOTH)
  20. tk.Label(gridFrame, padx=5, pady=5, text="{:32s}".format("Messwerte")).grid(row=0, column=0)
  21. self.rowCountLabel = tk.Label(gridFrame, padx=5, pady=5, text="")
  22. self.rowCountLabel.grid(row=0, column=1)
  23. self.sysLabels = []
  24. for i in range(1, len(self.controller.columnNames)):
  25. name = controller.columnNames[i]
  26. la = tk.Label(gridFrame, fg='red', padx=5, pady=5, text="{:32s}".format(name))
  27. la.grid(row=i, column=0)
  28. lb = tk.Label(gridFrame, fg='red', padx=5, pady=5, text="")
  29. lb.grid(row=i, column=1)
  30. self.sysLabels.append((la, lb))
  31. def update(self, visible):
  32. if visible:
  33. self.controller.intervalDelay = self.intervalSlider.get()
  34. row = self.controller.getLastRows(1)[0]
  35. for i in range(len(row)):
  36. nameLabel, valueLabel = self.sysLabels[i]
  37. color = 'red' if np.isnan(row[i]) else 'black' if row[i] == 0 else 'green'
  38. nameLabel.config( fg = color)
  39. valueLabel.config(fg = color, text="{:5.4f}".format(row[i]))
  40. self.rowCountLabel.config(text="{:d} / {:d}".format(min(self.controller.rowIndex, self.controller.nRows), self.controller.nRows))