From 95392cc6e06991b34505e479fae90981ee5182a5 Mon Sep 17 00:00:00 2001 From: Shikiryu Date: Thu, 25 May 2023 01:19:38 +0200 Subject: [PATCH] :construction: Starts sessions --- src/window/app.py | 11 +++++++++++ src/window/session.py | 25 +++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 src/window/session.py diff --git a/src/window/app.py b/src/window/app.py index 358cfcd..f685a11 100644 --- a/src/window/app.py +++ b/src/window/app.py @@ -4,11 +4,13 @@ from pathlib import Path from src.util import Util from functools import partial from src.window.image import ImageWindow +from src.window.session import SessionWindow class App: def __init__(self, root): super().__init__() + self.session_window = None self.image_window = None self.root = root self.selected_folder = "" @@ -41,6 +43,11 @@ class App: self.button_frame.columnconfigure(i, weight=1) new_button.grid(row=0, column=i, sticky=W + E) i += 1 + + new_button = Button(self.button_frame, text="Custom", command=self.custom_session) + self.buttons.append(new_button) + self.button_frame.columnconfigure(i, weight=1) + new_button.grid(row=0, column=i, sticky=W + E) self.launch_button = Button(root, text="Let's draw!", command=self.lets_draw, state="disabled") self.launch_button.pack(side="bottom") @@ -49,6 +56,10 @@ class App: self.image_window = ImageWindow(self) self.image_window.lets_draw(self.found_images.copy(), self.timer) + def custom_session(self): + self.session_window = SessionWindow(self) + self.session_window.open(self) + def select_folder(self): self.selected_folder = filedialog.askdirectory() self.found_images = list( diff --git a/src/window/session.py b/src/window/session.py new file mode 100644 index 0000000..1fb99d6 --- /dev/null +++ b/src/window/session.py @@ -0,0 +1,25 @@ +from tkinter import * + + +class SessionWindow: + def __init__(self, app): + self.app = app + + self.window = Toplevel(app.root) + self.window.title("Custom session") + self.window.geometry("600x600") + self.window.protocol("WM_DELETE_WINDOW", self.save_on_closing) + + self.list_in_session = [] + + self.update_session_list() + + + def update_session_list(self): + for i, session in enumerate(self.list_in_session): + new_session = Button(text="") + new_session.grid(row=i, column=0) + + def save_on_closing(self): + # TODO save + self.window.destroy()