Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: mismatch between required Pillow version and monitoring implementation #44

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions examples/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def label(
if position not in ["A", "B", "X", "Y"]:
raise ValueError(f"Invalid label position {position}")

text_w, text_h = self._draw.textsize(text, font=self.font)
_, _, text_w, text_h = self._draw.textbbox((0, 0), text, font=self.font)
text_h = 11
text_w += margin * 2
text_h += margin * 2
Expand Down Expand Up @@ -143,7 +143,7 @@ def text_in_rect(self, text, font, rect, line_spacing=1.1, textcolor=(0, 0, 0)):

while (
len(words) > 0
and font.getsize(" ".join(line + [words[0]]))[0] <= width
and font.getbbox(" ".join(line + [words[0]]))[2] <= width
):
line.append(words.pop(0))

Expand All @@ -161,7 +161,7 @@ def text_in_rect(self, text, font, rect, line_spacing=1.1, textcolor=(0, 0, 0)):
bounds = [x2, y, x1, y + len(lines) * line_height]

for line in lines:
line_width = font.getsize(line)[0]
line_width = font.getbbox(line)[2]
x = int(x1 + (width / 2) - (line_width / 2))
bounds[0] = min(bounds[0], x)
bounds[2] = max(bounds[2], x + line_width)
Expand Down Expand Up @@ -222,7 +222,7 @@ def render_channel(self, channel):
self.icon(icon_channel, (x, label_y), (200, 200, 200) if active else (64, 64, 64))

# TODO: replace number text with graphic
tw, th = self.font.getsize(str(channel.channel))
_, _, tw, th = self.font.getbbox(str(channel.channel))
self._draw.text(
(x + int(math.ceil(8 - (tw / 2.0))), label_y + 1),
str(channel.channel),
Expand Down Expand Up @@ -479,7 +479,7 @@ def render(self):

self.icon(icon_channel, (label_x, label_y), (200, 200, 200))

tw, th = self.font.getsize(str(self.channel.channel))
_, _, tw, th = self.font.getbbox(str(self.channel.channel))
self._draw.text(
(label_x + int(math.ceil(8 - (tw / 2.0))), label_y + 1),
str(self.channel.channel),
Expand Down