update layout

This commit is contained in:
barry 2025-01-11 19:04:17 +01:00
parent 9765756d7b
commit 0627a480f3

View File

@ -124,7 +124,7 @@ def display_loop(api: Api, cfg: Dict):
bg.paste(img, (10, 30))
draw = ImageDraw.Draw(bg)
draw.text(
(145, 33),
(145, 34),
"\n".join(textwrap.wrap(", ".join(data["artists"]), width=16)),
font=Font1,
fill=cfg["color_theme"]["text"],
@ -137,7 +137,7 @@ def display_loop(api: Api, cfg: Dict):
)
w, h = bg.size
w -= 95
w -= 90
progress_time = min(
data["duration_ms"],
data["progress_ms"] + int((time.time() - last_api_call) * 1000),
@ -161,23 +161,22 @@ def display_loop(api: Api, cfg: Dict):
[(10, h - 20), (10 + bar_width, h - 10)],
fill=cfg["color_theme"]["bar_inside"],
)
f_current_time = "{:02.0f}:{:02.0f}".format(
f_current_time = "{}:{:02.0f}".format(
*divmod(progress_time // 1000, 60)
)
f_total_time = "{:02d}:{:02d}".format(
f_total_time = "{}:{:02d}".format(
*divmod(data["duration_ms"] // 1000, 60)
)
draw.rectangle(
[(231, 215), (320, 235)], fill=cfg["color_theme"]["background"]
[(239, 215), (320, 235)], fill=cfg["color_theme"]["background"]
)
draw.text(
(232, 220),
(240, 220),
f"{f_current_time}/{f_total_time}",
font=Font0,
fill=cfg["color_theme"]["text"],
)
d.ShowImage(bg)
print(bar_width)
time.sleep(cfg["refresh_interval"])
except IOError as e: