2019-11-22 20:59:22 +00:00
|
|
|
"status bar"
|
2019-11-25 19:23:04 +00:00
|
|
|
import tkinter as tk
|
2019-11-22 20:59:22 +00:00
|
|
|
from tkinter import ttk
|
|
|
|
|
2019-12-19 17:30:21 +00:00
|
|
|
from core.gui.dialogs.alerts import AlertsDialog
|
|
|
|
from core.gui.themes import Styles
|
2019-12-11 17:17:39 +00:00
|
|
|
|
2019-11-22 20:59:22 +00:00
|
|
|
|
|
|
|
class StatusBar(ttk.Frame):
|
|
|
|
def __init__(self, master, app, **kwargs):
|
|
|
|
super().__init__(master, **kwargs)
|
|
|
|
self.app = app
|
|
|
|
self.status = None
|
2019-11-25 19:23:04 +00:00
|
|
|
self.statusvar = tk.StringVar()
|
2019-11-26 00:50:44 +00:00
|
|
|
self.progress_bar = None
|
2019-11-22 20:59:22 +00:00
|
|
|
self.zoom = None
|
|
|
|
self.cpu_usage = None
|
|
|
|
self.memory = None
|
2019-12-13 05:05:45 +00:00
|
|
|
self.alerts_button = None
|
2019-11-22 22:55:10 +00:00
|
|
|
self.running = False
|
2019-12-13 00:17:33 +00:00
|
|
|
self.core_alarms = []
|
2019-11-22 20:59:22 +00:00
|
|
|
self.draw()
|
|
|
|
|
|
|
|
def draw(self):
|
2019-11-26 00:50:44 +00:00
|
|
|
self.columnconfigure(0, weight=1)
|
|
|
|
self.columnconfigure(1, weight=7)
|
2019-11-22 20:59:22 +00:00
|
|
|
self.columnconfigure(2, weight=1)
|
|
|
|
self.columnconfigure(3, weight=1)
|
2019-11-26 00:50:44 +00:00
|
|
|
self.columnconfigure(4, weight=1)
|
|
|
|
|
2019-12-09 23:27:51 +00:00
|
|
|
frame = ttk.Frame(self, borderwidth=1, relief=tk.RIDGE)
|
|
|
|
frame.grid(row=0, column=0, sticky="ew")
|
|
|
|
frame.columnconfigure(0, weight=1)
|
2019-11-26 00:50:44 +00:00
|
|
|
self.progress_bar = ttk.Progressbar(
|
2019-12-09 23:27:51 +00:00
|
|
|
frame, orient="horizontal", mode="indeterminate"
|
2019-11-26 00:50:44 +00:00
|
|
|
)
|
2019-12-09 23:27:51 +00:00
|
|
|
self.progress_bar.grid(sticky="ew")
|
2019-11-28 00:14:14 +00:00
|
|
|
|
2019-12-09 23:27:51 +00:00
|
|
|
self.status = ttk.Label(
|
|
|
|
self,
|
|
|
|
textvariable=self.statusvar,
|
|
|
|
anchor=tk.CENTER,
|
|
|
|
borderwidth=1,
|
|
|
|
relief=tk.RIDGE,
|
|
|
|
)
|
2019-11-28 00:14:14 +00:00
|
|
|
self.status.grid(row=0, column=1, sticky="ew")
|
|
|
|
|
2019-12-09 23:27:51 +00:00
|
|
|
self.zoom = ttk.Label(
|
2019-12-16 20:04:18 +00:00
|
|
|
self,
|
|
|
|
text="%s" % (int(self.app.canvas.ratio * 100)) + "%",
|
|
|
|
anchor=tk.CENTER,
|
|
|
|
borderwidth=1,
|
|
|
|
relief=tk.RIDGE,
|
2019-12-09 23:27:51 +00:00
|
|
|
)
|
2019-11-28 00:14:14 +00:00
|
|
|
self.zoom.grid(row=0, column=2, sticky="ew")
|
|
|
|
|
2019-12-09 23:27:51 +00:00
|
|
|
self.cpu_usage = ttk.Label(
|
|
|
|
self, text="CPU TBD", anchor=tk.CENTER, borderwidth=1, relief=tk.RIDGE
|
|
|
|
)
|
2019-11-28 00:14:14 +00:00
|
|
|
self.cpu_usage.grid(row=0, column=3, sticky="ew")
|
|
|
|
|
2019-12-13 05:05:45 +00:00
|
|
|
self.alerts_button = ttk.Button(
|
|
|
|
self, text="Alerts", command=self.click_alerts, style=Styles.green_alert
|
2019-12-09 23:27:51 +00:00
|
|
|
)
|
2019-12-13 05:05:45 +00:00
|
|
|
self.alerts_button.grid(row=0, column=4, sticky="ew")
|
2019-11-22 22:55:10 +00:00
|
|
|
|
2019-12-13 05:05:45 +00:00
|
|
|
def click_alerts(self):
|
|
|
|
dialog = AlertsDialog(self.app, self.app)
|
2019-12-11 17:17:39 +00:00
|
|
|
dialog.show()
|
|
|
|
|
2019-11-26 00:50:44 +00:00
|
|
|
def start_session_callback(self, process_time):
|
|
|
|
self.progress_bar.stop()
|
2019-12-09 23:27:51 +00:00
|
|
|
self.statusvar.set(f"Session started in {process_time:.3f} seconds")
|
2019-11-26 19:30:25 +00:00
|
|
|
|
|
|
|
def stop_session_callback(self, cleanup_time):
|
|
|
|
self.progress_bar.stop()
|
2019-12-09 23:27:51 +00:00
|
|
|
self.statusvar.set(f"Stopped session in {cleanup_time:.3f} seconds")
|