|
@@ -6,15 +6,20 @@ import numpy as np
|
|
|
|
|
|
from gui.popup import CalibrationPopUp
|
|
|
from gui.graph import Graph
|
|
|
+from gui.Logscreen import LogScreen
|
|
|
|
|
|
|
|
|
class MainWindow(tk.Frame):
|
|
|
- def __init__(self, root, ac_sensor, ac_queue, ac_cal_state):
|
|
|
+ def __init__(self, root, ac_sensor, ac_queue, ac_cal_state, log_handler):
|
|
|
self.root = root
|
|
|
self.popup = None
|
|
|
+ self.log_window = None
|
|
|
self.ac_cal_state = ac_cal_state
|
|
|
self.ac_sensor = ac_sensor
|
|
|
self.ac_queue = ac_queue
|
|
|
+ self.log_handler = log_handler
|
|
|
+ self.log_handler.add_item("start Main Window")
|
|
|
+
|
|
|
tk.Frame.__init__(self, root)
|
|
|
# data plot at left side
|
|
|
self.graph = Graph(self)
|
|
@@ -46,6 +51,9 @@ class MainWindow(tk.Frame):
|
|
|
clear_button = tk.Button(self.controls, text="Clear graph", command=self.graph.clear, height=4)
|
|
|
clear_button.pack(side="bottom", fill="both")
|
|
|
|
|
|
+ logscreen_button = tk.Button(self.controls, text="Log", command=self.open_log, height=2, foreground="red")
|
|
|
+ logscreen_button.pack(side="bottom", fill="both")
|
|
|
+
|
|
|
def update(self):
|
|
|
if not self.root.winfo_exists():
|
|
|
return
|
|
@@ -89,11 +97,15 @@ class MainWindow(tk.Frame):
|
|
|
|
|
|
if self.popup:
|
|
|
self.popup.update()
|
|
|
+
|
|
|
+ if self.log_window:
|
|
|
+ self.log_window.update()
|
|
|
|
|
|
self.root.after(30, self.update)
|
|
|
|
|
|
def calibrate(self):
|
|
|
self.ac_sensor.start_calibration()
|
|
|
+ self.log_handler.add_item("start calibration")
|
|
|
if not self.popup or not self.pu_root.winfo_exists():
|
|
|
# create new window
|
|
|
self.pu_root = tk.Toplevel(self.root)
|
|
@@ -108,3 +120,17 @@ class MainWindow(tk.Frame):
|
|
|
self.popup = CalibrationPopUp(self.pu_root, self.ac_cal_state)
|
|
|
self.popup.pack(side="top", fill="both", expand=True)
|
|
|
|
|
|
+ def open_log(self):
|
|
|
+ #create new window
|
|
|
+ self.log_root = tk.Toplevel(self.root)
|
|
|
+ self.log_root.wm_transient(self.root)
|
|
|
+ self.log_root.wm_title("Logs")
|
|
|
+ #center
|
|
|
+ x = (self.log_root.winfo_screenwidth() - 1000) / 2
|
|
|
+ y = (self.log_root.winfo_screenheight() - 400) / 2
|
|
|
+ self.log_root.geometry(f'1000x400+{int(x)}+{int(y)}')
|
|
|
+ # deactivate mainWindow
|
|
|
+ self.log_root.grab_set()
|
|
|
+ self.log_window = LogScreen(self.log_root,self.log_handler)
|
|
|
+ self.log_window.pack(side="top", fill="both", expand=True)
|
|
|
+
|