[modules/cpu] Pad to 3 digits before comma to fix width

I cannot get the min_width property to work right now, so in order to
fix the width of the CPU widget, pad the utilization to 3 digits (so
that even 100% aligns nicely).

see #23
This commit is contained in:
Tobi-wan Kenobi 2016-12-10 09:04:12 +01:00
parent 38a42e4a77
commit 761b81970d
2 changed files with 2 additions and 2 deletions

View file

@ -22,7 +22,7 @@ class Module(bumblebee.engine.Module):
cmd="gnome-system-monitor") cmd="gnome-system-monitor")
def utilization(self): def utilization(self):
return "{:05.02f}%".format(self._utilization) return "{:06.02f}%".format(self._utilization)
def update(self, widgets): def update(self, widgets):
self._utilization = psutil.cpu_percent(percpu=False) self._utilization = psutil.cpu_percent(percpu=False)

View file

@ -22,7 +22,7 @@ class TestCPUModule(unittest.TestCase):
@mock.patch("sys.stdout") @mock.patch("sys.stdout")
def test_format(self, mock_output): def test_format(self, mock_output):
for widget in self.module.widgets(): for widget in self.module.widgets():
self.assertEquals(len(widget.full_text()), len("00.00%")) self.assertEquals(len(widget.full_text()), len("100.00%"))
@mock.patch("subprocess.Popen") @mock.patch("subprocess.Popen")
@mock.patch("sys.stdin") @mock.patch("sys.stdin")