start implementing edit_recipe
This commit is contained in:
@@ -1,16 +1,17 @@
|
||||
import io
|
||||
import tkinter as tk
|
||||
from tkinter import Frame, Canvas, ttk, PhotoImage
|
||||
from enum import Enum
|
||||
|
||||
from PIL import ImageChops
|
||||
|
||||
from ..config import DISPLAY_TYPES, DISPLAY_MODES
|
||||
from .draw_utils import draw_clock
|
||||
from . import NumberView, CircleView, TimerView
|
||||
|
||||
from .button_interface import ButtonInterface
|
||||
from .buttons_manager import ButtonsManager
|
||||
from .recipes.recipe_selection import RecipeSelection
|
||||
from .draw_utils import draw_clock
|
||||
|
||||
from .recipes import RecipeSelection, RecipeManager, EditRecipe, Recipe
|
||||
|
||||
class MainView(tk.Frame, ButtonInterface):
|
||||
def __init__(self, parent,
|
||||
@@ -38,10 +39,9 @@ class MainView(tk.Frame, ButtonInterface):
|
||||
|
||||
|
||||
self.timer_view = TimerView(self.actions, self.im_size, self.center)
|
||||
self.recipe_selection = RecipeSelection(self, self.im_size, self.center, deactivate_command=self.enter_main_mode)
|
||||
self.buttons = ButtonsManager(self, self.im_size, self.center,
|
||||
default=self,
|
||||
select_recipe=self.recipe_selection)
|
||||
curr_view=self)
|
||||
self.recipes_manager = RecipeManager()
|
||||
|
||||
self.curr_mode = DISPLAY_MODES.MAIN
|
||||
|
||||
@@ -82,10 +82,22 @@ class MainView(tk.Frame, ButtonInterface):
|
||||
|
||||
def enter_recipe_selection(self):
|
||||
self.curr_mode = DISPLAY_MODES.RECIPE_SELECTION
|
||||
self.buttons.current_view = self.recipe_selection
|
||||
self.buttons.current_view = RecipeSelection(self,
|
||||
self.im_size, self.center,
|
||||
recipe_manager=self.recipes_manager,
|
||||
edit_recipe_command=self.enter_edit_recipe,
|
||||
deactivate_command=self.enter_main_mode)
|
||||
self.refresh(0.0)
|
||||
|
||||
|
||||
|
||||
def enter_edit_recipe(self, recipe: Recipe = None):
|
||||
self.curr_mode = DISPLAY_MODES.EDIT_RECIPE
|
||||
self.buttons.current_view = EditRecipe(self,
|
||||
self.im_size, self.center,
|
||||
recipe=recipe,
|
||||
recipe_manager=self.recipes_manager,
|
||||
deactivate_command=self.enter_recipe_selection)
|
||||
self.refresh(0.0)
|
||||
|
||||
################ VIEW MANAGEMENT ################
|
||||
|
||||
def update_views(self, selected_types: DISPLAY_TYPES):
|
||||
@@ -120,10 +132,10 @@ class MainView(tk.Frame, ButtonInterface):
|
||||
im = view.update_weight(weight)
|
||||
ims.append(im)
|
||||
|
||||
elif self.curr_mode == DISPLAY_MODES.RECIPE_SELECTION:
|
||||
else:
|
||||
button_im = self.buttons.update_weight(weight)
|
||||
ims.append(button_im)
|
||||
recipe_im = self.recipe_selection.update_weight(weight)
|
||||
recipe_im = self.buttons.current_view.update_weight(weight)
|
||||
ims.append(recipe_im)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user