From 658e96c6d31f1ed25dbddcd1de25ffa60f3c7005 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 | 6 +++--- src/window/session.py | 41 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/src/window/app.py b/src/window/app.py index f685a11..872e778 100644 --- a/src/window/app.py +++ b/src/window/app.py @@ -43,7 +43,7 @@ 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) @@ -58,8 +58,8 @@ class App: def custom_session(self): self.session_window = SessionWindow(self) - self.session_window.open(self) - + self.session_window.open() + 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 index 1fb99d6..d10c026 100644 --- a/src/window/session.py +++ b/src/window/session.py @@ -1,8 +1,12 @@ +from functools import partial from tkinter import * class SessionWindow: def __init__(self, app): + self.selected_element_index = 0 + self.delete_button = None + self.add_button = None self.app = app self.window = Toplevel(app.root) @@ -10,16 +14,51 @@ class SessionWindow: self.window.geometry("600x600") self.window.protocol("WM_DELETE_WINDOW", self.save_on_closing) + self.left_column = Frame(self.window, width=300, height=600) + self.right_column = Frame(self.window, width=300, height=600) + + self.left_column.grid(row=0, column=0, sticky="ns") + self.right_column.grid(row=0, column=1, sticky="ns") + self.list_in_session = [] + def open(self): self.update_session_list() + self.add_button = Button(self.left_column, text="+", command=self.add_element) + self.add_button.pack() + + self.delete_button = Button(self.left_column, text="-", command=self.remove_element) + self.delete_button.pack() def update_session_list(self): for i, session in enumerate(self.list_in_session): - new_session = Button(text="") + new_session = Button(self.left_column, text="element " + str(i), command=partial(self.edit_element, i)) new_session.grid(row=i, column=0) + def remove_element(self): + self.list_in_session.pop(self.selected_element_index) + + def edit_element(self, i): + self.selected_element_index = i + element = self.list_in_session[self.selected_element_index] + + number_of_drawings_label = Text(self.right_column) + number_of_drawings_label.insert(INSERT, "Nombre de dessins :") + number_of_drawings_label.pack() + + number_of_drawings_input = Entry(self.right_column) + number_of_drawings_input.insert(INSERT, element.number_of_drawings) + number_of_drawings_input.pack() + + def add_element(self): + number_of_drawings_label = Text(self.right_column) + number_of_drawings_label.insert(INSERT, "Nombre de dessins :") + number_of_drawings_label.pack() + + number_of_drawings_input = Entry(self.right_column) + number_of_drawings_input.pack() + def save_on_closing(self): # TODO save self.window.destroy()