From 1f443e97d53c63b27460760c52d9f2bb0187e196 Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Sat, 6 Jan 2024 20:10:24 -0500 Subject: [PATCH] Ensure status icons always drawn in same place --- py/hexagram/status.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/py/hexagram/status.py b/py/hexagram/status.py index 17d6ec9..c72e3b5 100644 --- a/py/hexagram/status.py +++ b/py/hexagram/status.py @@ -298,18 +298,21 @@ class StatusIconBox(Gauge): x, y = 0, self.height - self.ICON_HEIGHT - for typeof in self.statuses: - status = self.statuses[typeof] - icon = self.icons[typeof] + for icon_type in self.ICONS: + typeof = icon_type.TYPE + status = self.statuses.get(typeof) - if icon.drawable(status): - icon.draw(cr, x, y, status) + if status is not None: + icon = self.icons[typeof] - x += self.ICON_WIDTH + if icon.drawable(status): + icon.draw(cr, x, y, status) - if x >= self.width: - x = 0 - y -= self.ICON_HEIGHT + x += self.ICON_WIDTH + + if x >= self.width: + x = 0 + y -= self.ICON_HEIGHT def draw_fg(self, cr: cairo.Context): if self._redraw: