diff --git a/cromulant/game.py b/cromulant/game.py index 119ba3d..c1d2c20 100644 --- a/cromulant/game.py +++ b/cromulant/game.py @@ -46,7 +46,8 @@ class Game: elif ant.method == "thinking": status = f"Thinking about {status}" - image_label = Game.get_image(Config.status_image_path, color) + tooltip = Utils.to_date(ant.updated) + image_label = Game.get_image(Config.status_image_path, color, tooltip=tooltip) right_container = Game.make_right_container(ant.name, status) container.addWidget(image_label) @@ -104,7 +105,8 @@ class Game: @staticmethod def get_image( - image_path: Path, color: tuple[int, int, int] | None = None + image_path: Path, color: tuple[int, int, int] | None = None, + tooltip: str = "" ) -> QLabel: image_label = QLabel() pixmap = QPixmap(str(image_path)) @@ -123,6 +125,9 @@ class Game: rgb = Utils.get_rgb(color) image_label.setStyleSheet(f"border: 2px solid {rgb};") + if tooltip: + image_label.setToolTip(tooltip) + image_label.mousePressEvent = lambda event: Game.toggle_song() return image_label diff --git a/cromulant/utils.py b/cromulant/utils.py index 04a4f63..09f7e4e 100644 --- a/cromulant/utils.py +++ b/cromulant/utils.py @@ -3,6 +3,7 @@ from __future__ import annotations import random import colorsys import time +from datetime import datetime from typing import ClassVar from fontTools.ttLib import TTFont # type: ignore @@ -108,3 +109,9 @@ class Utils: @staticmethod def get_random_emoji(num: int) -> str: return Utils.get_random_character(str(Config.emoji_font_path), num) + + @staticmethod + def to_date(timestamp: float) -> str: + dt_object = datetime.fromtimestamp(timestamp) + hour = dt_object.strftime("%I").lstrip("0") + return dt_object.strftime(f"%b %d %Y - {hour}:%M %p") \ No newline at end of file