🚧 Starts sessions

This commit is contained in:
Shikiryu 2023-05-25 01:19:38 +02:00
parent 95392cc6e0
commit 658e96c6d3
2 changed files with 43 additions and 4 deletions

View File

@ -58,7 +58,7 @@ class App:
def custom_session(self): def custom_session(self):
self.session_window = SessionWindow(self) self.session_window = SessionWindow(self)
self.session_window.open(self) self.session_window.open()
def select_folder(self): def select_folder(self):
self.selected_folder = filedialog.askdirectory() self.selected_folder = filedialog.askdirectory()

View File

@ -1,8 +1,12 @@
from functools import partial
from tkinter import * from tkinter import *
class SessionWindow: class SessionWindow:
def __init__(self, app): def __init__(self, app):
self.selected_element_index = 0
self.delete_button = None
self.add_button = None
self.app = app self.app = app
self.window = Toplevel(app.root) self.window = Toplevel(app.root)
@ -10,16 +14,51 @@ class SessionWindow:
self.window.geometry("600x600") self.window.geometry("600x600")
self.window.protocol("WM_DELETE_WINDOW", self.save_on_closing) 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 = [] self.list_in_session = []
def open(self):
self.update_session_list() 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): def update_session_list(self):
for i, session in enumerate(self.list_in_session): 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) 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): def save_on_closing(self):
# TODO save # TODO save
self.window.destroy() self.window.destroy()