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')