start implementing edit_recipe
This commit is contained in:
34
frontend/views/confirm.py
Normal file
34
frontend/views/confirm.py
Normal file
@@ -0,0 +1,34 @@
|
||||
from .base import View
|
||||
from ..button_interface import ButtonInterface
|
||||
|
||||
class ConfirmView(View, ButtonInterface):
|
||||
def __init__(self, parent, im_size, center,
|
||||
message: str,
|
||||
confirm_command,
|
||||
cancel_command):
|
||||
self.message = message
|
||||
self.confirm_command = confirm_command
|
||||
self.cancel_command = cancel_command
|
||||
super().__init__(parent, im_size, center)
|
||||
|
||||
def update_weight(self, weight: float):
|
||||
from PIL import ImageDraw
|
||||
|
||||
im = self.bkg_im.copy()
|
||||
draw = ImageDraw.Draw(im)
|
||||
|
||||
draw.text((20, 60), self.message, fill='black')
|
||||
|
||||
return im
|
||||
|
||||
def render_left_long_press(self, draw, x, y):
|
||||
draw.text((x, y), 'Confirm', fill='black')
|
||||
|
||||
def render_right_press(self, draw, x, y):
|
||||
draw.text((x, y), 'Cancel', fill='black')
|
||||
|
||||
def left_press(self):
|
||||
self.confirm_command()
|
||||
|
||||
def right_press(self):
|
||||
self.cancel_command()
|
||||
Reference in New Issue
Block a user