add recipe class

This commit is contained in:
Jannes Magnusson
2025-10-18 20:15:11 +02:00
parent d619ec1859
commit 06df2e0e9b
7 changed files with 198 additions and 70 deletions

View File

@@ -0,0 +1,39 @@
from typing import Tuple
from PIL import ImageDraw, Image
from ..base import View
from ..button_interface import ButtonInterface
class AddRecipe(View, ButtonInterface):
def __init__(self, parent, im_size, center,
save_command=None, cancel_command=None):
self.save_command = save_command
self.cancel_command = cancel_command
super().__init__(parent, im_size, center)
def update_weight(self, weight: float) -> Image.Image:
im = self.bkg_im.copy()
draw = ImageDraw.Draw(im)
draw.text((40, 30), "Add Recipe", fill='black')
draw.text((40, 60), "Save", fill='black')
draw.text((40, 90), "Cancel", fill='black')
return im
def left_press(self):
if self.save_command:
self.save_command()
def right_press(self):
if self.cancel_command:
self.cancel_command()
def has_button(self) -> Tuple[bool, bool, bool, bool]:
return True, False, True, False
def render_left_press(self, draw, x, y):
draw.text((x, y), 'Save', fill='black')
def render_right_press(self, draw, x, y):
draw.text((x, y), 'Cancel', fill='black')