23 lines
682 B
Python
23 lines
682 B
Python
|
|
from __future__ import annotations
|
||
|
|
import toga
|
||
|
|
|
||
|
|
from ..forms.recipe_form import RecipeForm
|
||
|
|
|
||
|
|
|
||
|
|
class EditRecipeView(toga.Box):
|
||
|
|
def __init__(self, app: toga.App, recipe_id: int | None = None):
|
||
|
|
super().__init__(style=toga.style.Pack(direction="column", margin=8))
|
||
|
|
self.recipe_id = recipe_id
|
||
|
|
self.app = app
|
||
|
|
self._setup()
|
||
|
|
|
||
|
|
def _setup(self):
|
||
|
|
label_text = (
|
||
|
|
f"Edit Recipe {self.recipe_id}" if self.recipe_id is not None else "New Recipe"
|
||
|
|
)
|
||
|
|
self.add(toga.Label(label_text, style=toga.style.Pack(font_size=16)))
|
||
|
|
# Embed the placeholder RecipeForm
|
||
|
|
self.add(RecipeForm())
|
||
|
|
|
||
|
|
|
||
|
|
__all__ = ["EditRecipeView"]
|