Page_4.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. label = tk.Label(frame, text="Einstellungen", font=LARGE_FONT)
  15. label.pack(pady=10,padx=10)
  16. tk.Label(frame, text="Aktualisierungsinterval in ms").pack()
  17. self.intervalSlider = tk.Scale(frame, from_=50, to=1000, resolution=10, orient=tk.HORIZONTAL)
  18. self.intervalSlider.set(300)
  19. self.intervalSlider.pack(side="top", fill="both", padx=5, pady=5)
  20. gridFrame = tk.LabelFrame(self, text="System Check")
  21. gridFrame.pack(side=tk.LEFT, fill=tk.BOTH)
  22. self.sysLabels = []
  23. for i in range(1, len(self.controller.columnNames)):
  24. name = controller.columnNames[i]
  25. la = tk.Label(gridFrame, fg='red', padx=5, pady=5, text="{:32s}".format(name))
  26. la.grid(row=i, column=0)
  27. lb = tk.Label(gridFrame, fg='red', padx=5, pady=5, text="")
  28. lb.grid(row=i, column=1)
  29. self.sysLabels.append((la, lb))
  30. def update(self, visible):
  31. if visible:
  32. self.controller.intervalDelay = self.intervalSlider.get()
  33. row = self.controller.getLastRows(1)[0]
  34. for i in range(len(row)):
  35. nameLabel, valueLabel = self.sysLabels[i]
  36. color = 'red' if np.isnan(row[i]) else 'black' if row[i] == 0 else 'green'
  37. nameLabel.config( fg = color)
  38. valueLabel.config(fg = color, text="{:5.4f}".format(row[i]))