From e2546c7bfb1b7e1203272d8200d8e51e4fbb5325 Mon Sep 17 00:00:00 2001 From: Shikiryu Date: Fri, 2 Jun 2023 09:38:35 +0200 Subject: [PATCH] :construction: Save session to app --- src/window/app.py | 9 +++++++-- src/window/session.py | 7 ++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/window/app.py b/src/window/app.py index a665a17..65b70c7 100644 --- a/src/window/app.py +++ b/src/window/app.py @@ -12,7 +12,9 @@ from src.window.session import SessionWindow class App: def __init__(self, root): super().__init__() + self.custom = False self.config = Config() + self.session = None self.session_window = None self.image_window = None self.root = root @@ -41,7 +43,6 @@ class App: t = i new_button = Button(self.button_frame, text=Util.format_seconds(t), command=partial(self.set_timer_in_seconds, t)) - self.buttons.append(new_button) self.button_frame.columnconfigure(i, weight=1) new_button.grid(row=0, column=i, sticky=W + E) @@ -72,7 +73,7 @@ class App: self.check_lets_draw() def check_lets_draw(self): - if self.selected_folder != "" and len(self.found_images) > 0 and self.timer != 0: + if self.selected_folder != "" and len(self.found_images) > 0 and (self.timer != 0 or self.custom): self.launch_button.config(state="normal") else: self.launch_button.config(state="disabled") @@ -85,3 +86,7 @@ class App: else: button.config(bg="gray85") self.check_lets_draw() + + def set_custom(self, list_in_session): + self.custom = True + self.list_in_session = list_in_session diff --git a/src/window/session.py b/src/window/session.py index f2d574c..1c83a65 100644 --- a/src/window/session.py +++ b/src/window/session.py @@ -58,8 +58,8 @@ class SessionWindow: self.down_button = Button(button_frame, text="v", command=self.down_element) self.down_button.pack(side=LEFT, padx=0, pady=0) - self.save_session_button = Button(button_frame, text="v", command=self.save_session) - self.save_session_button.pack(side=LEFT, padx=0, pady=0) + save_session_button = Button(button_frame, text="v", command=self.save_session) + save_session_button.pack(side=LEFT, padx=0, pady=0) button_frame.grid() def reset_element(self): @@ -156,6 +156,7 @@ class SessionWindow: def save_session(self): for element in self.list_in_session: - Config._CONFIG['session'].append(element) + Config._CONFIG['session'].append(element.__dict__) Config.save() + self.app.set_custom(self.list_in_session) self.window.destroy()