This commit is contained in:
Auric Vente 2024-07-19 19:44:58 -06:00
parent d8e7776937
commit 554cd1af72
2 changed files with 14 additions and 2 deletions

View File

@ -46,7 +46,8 @@ class Game:
elif ant.method == "thinking": elif ant.method == "thinking":
status = f"Thinking about {status}" 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) right_container = Game.make_right_container(ant.name, status)
container.addWidget(image_label) container.addWidget(image_label)
@ -104,7 +105,8 @@ class Game:
@staticmethod @staticmethod
def get_image( 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: ) -> QLabel:
image_label = QLabel() image_label = QLabel()
pixmap = QPixmap(str(image_path)) pixmap = QPixmap(str(image_path))
@ -123,6 +125,9 @@ class Game:
rgb = Utils.get_rgb(color) rgb = Utils.get_rgb(color)
image_label.setStyleSheet(f"border: 2px solid {rgb};") image_label.setStyleSheet(f"border: 2px solid {rgb};")
if tooltip:
image_label.setToolTip(tooltip)
image_label.mousePressEvent = lambda event: Game.toggle_song() image_label.mousePressEvent = lambda event: Game.toggle_song()
return image_label return image_label

View File

@ -3,6 +3,7 @@ from __future__ import annotations
import random import random
import colorsys import colorsys
import time import time
from datetime import datetime
from typing import ClassVar from typing import ClassVar
from fontTools.ttLib import TTFont # type: ignore from fontTools.ttLib import TTFont # type: ignore
@ -108,3 +109,9 @@ class Utils:
@staticmethod @staticmethod
def get_random_emoji(num: int) -> str: def get_random_emoji(num: int) -> str:
return Utils.get_random_character(str(Config.emoji_font_path), num) 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")