Files

56 lines
2.0 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import os
from PIL import Image, ImageDraw
class AboutApp:
kind = 'about'
title = 'О системе'
icon = 'A'
cmd = 'about'
def __init__(self):
self.icon_img = None
self.logo_img = None
base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
try:
self.icon_img = Image.open(os.path.join(base_dir, 'assets', 'icon.png')).convert('1')
if self.icon_img.size != (8, 8):
self.icon_img = self.icon_img.resize((8, 8), Image.Resampling.LANCZOS)
except Exception:
pass
try:
self.logo_img = Image.open(os.path.join(base_dir, 'assets', 'logo.png')).convert('1')
if self.logo_img.size != (40, 40):
self.logo_img = self.logo_img.resize((40, 40), Image.Resampling.LANCZOS)
except Exception:
pass
def render(self, fonts, bg, now):
img = Image.new('1', (128, 64), 1) # Белый фон
d = ImageDraw.Draw(img)
# Логотип 40x40 слева, по центру оставшегося места (высота панели 51, значит центр 25)
if self.logo_img:
img.paste(self.logo_img, (4, 5))
# Центр оставшегося места: от 48 до 127
center_x = (48 + 127) // 2
# Верхний текст (чуть больше)
d.text((center_x, 14), "OKNA 96 v1.0", font=fonts['small'], fill=0, anchor="mm")
d.text((center_x, 24), "RPi Alpha", font=fonts['small'], fill=0, anchor="mm")
# Нижний текст (меньше)
d.text((center_x, 36), "Адаптация для", font=fonts['tiny'], fill=0, anchor="mm")
d.text((center_x, 45), "LabStand 2.0", font=fonts['tiny'], fill=0, anchor="mm")
return img
def handle_key(self, code, mods, system):
if code == 1: # Esc
system._close_app('about')
return True
return False