From ccb3365e9a604d2f06cb8e3b17b036fe18e4b839 Mon Sep 17 00:00:00 2001 From: GridexX Date: Sun, 27 Feb 2022 14:16:32 +0100 Subject: [PATCH] feat(summaryFrame): initial summaryFrame --- process/summary_frame.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 process/summary_frame.py diff --git a/process/summary_frame.py b/process/summary_frame.py new file mode 100644 index 0000000..caea32d --- /dev/null +++ b/process/summary_frame.py @@ -0,0 +1,28 @@ + +from tkinter import StringVar +import tkinter as tk +import functools +from home import base_summary_frame +from process import read + + +class SummaryFrame(base_summary_frame.BaseSummaryFrame): + def __init__(self, master, logger, **options): + super().__init__(master, logger, **options) + + self.processCount = StringVar() + + + def show(self): + self.processLs = tk.Label(self, textvariable=self.processCount) + self.processLs.pack(fill=tk.BOTH, expand=True) + + + def update(self, dt): + result = read.read_process() + cpu_percent = round(functools.reduce(lambda x, y: {'cpu_percent': y['cpu_percent']+x['cpu_percent']}, result)['cpu_percent'], 2) + memory_percent = round(functools.reduce(lambda x, y: {'memory_percent': y['memory_percent']+x['memory_percent']}, result)['memory_percent'], 2) + + + self.processCount.set("Process : " + str(len(result)) + "\nCPU : "+str(cpu_percent) + " %\nRAM : " + str(memory_percent) + " %") +