From 061572a2e044443d9b208c18589e95994d922bb7 Mon Sep 17 00:00:00 2001 From: Srikanth Ravipati <rsri131@gmail.com> Date: Tue, 16 Mar 2021 09:24:17 +0000 Subject: [PATCH] Added parent to the memory-bar in memoryview and a few other changes --- qt/applications/workbench/workbench/plugins/memoryinfo.py | 3 ++- qt/applications/workbench/workbench/plugins/memoryview.py | 2 +- qt/applications/workbench/workbench/plugins/memorywidget.py | 6 ++---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/qt/applications/workbench/workbench/plugins/memoryinfo.py b/qt/applications/workbench/workbench/plugins/memoryinfo.py index d320160bec4..634e3e8924c 100644 --- a/qt/applications/workbench/workbench/plugins/memoryinfo.py +++ b/qt/applications/workbench/workbench/plugins/memoryinfo.py @@ -12,5 +12,6 @@ from psutil import virtual_memory def getMemoryUsed(): memory_used = virtual_memory().used memory_available = virtual_memory().available - memory_free_percent = int(round(memory_used * 100 / memory_available)) + memory_free = round(memory_used * 100 / memory_available) + memory_free_percent = min(int(memory_free), 100) return memory_free_percent diff --git a/qt/applications/workbench/workbench/plugins/memoryview.py b/qt/applications/workbench/workbench/plugins/memoryview.py index b9ed45c25df..c9dc44c2065 100644 --- a/qt/applications/workbench/workbench/plugins/memoryview.py +++ b/qt/applications/workbench/workbench/plugins/memoryview.py @@ -39,7 +39,7 @@ class MemoryView(QWidget): self.critical = 90 # For the future use, if needed #self.ui = load_ui(__file__, 'memorybar.ui', baseinstance=self) - self.memory_bar = QProgressBar() + self.memory_bar = QProgressBar(self) def setBarColor(self, currentValue, newValue): if (fromNormalToCritical(self.critical, currentValue, newValue)): diff --git a/qt/applications/workbench/workbench/plugins/memorywidget.py b/qt/applications/workbench/workbench/plugins/memorywidget.py index 8a66ee1133e..2d4a0e83c1c 100644 --- a/qt/applications/workbench/workbench/plugins/memorywidget.py +++ b/qt/applications/workbench/workbench/plugins/memorywidget.py @@ -18,13 +18,11 @@ class MemoryWidget(PluginWidget): def __init__(self, parent, view=None): super(MemoryWidget, self).__init__(parent) - view = MemoryView(self) - self.presenter = MemoryPresenter(view) - self.view = view if view else MemoryView(self) + self.presenter = MemoryPresenter(self.view) layout = QVBoxLayout() - layout.addWidget(view.memory_bar) + layout.addWidget(self.view.memory_bar) self.setLayout(layout) self.setWindowTitle(self.get_plugin_title()) -- GitLab