From 9d305a9623cf4ab99769dd4e8a05f6bdb9bf552c Mon Sep 17 00:00:00 2001 From: Shikiryu Date: Sat, 20 May 2023 14:40:17 +0200 Subject: [PATCH] :sparkles: Trying tkinter seems better --- tk.py | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 tk.py diff --git a/tk.py b/tk.py new file mode 100644 index 0000000..ed3276a --- /dev/null +++ b/tk.py @@ -0,0 +1,78 @@ +from tkinter import * +from tkinter import filedialog +from pathlib import Path +from functools import partial + +root = Tk() +root.title("Drawing Training!") +root.geometry("300x600") + +selected_folder = "" +found_images = [] +timer = 0 + + +def set_timer_in_seconds(user_data): + global timer + timer = user_data + print(timer) + for button in buttons: + if button['text'] == str(timer) + "s": + button.config(bg="blue") + else: + button.config(bg="grey") + + +def select_folder(): + global selected_folder + global found_images + global folder_name + global images_len + selected_folder = filedialog.askdirectory() + found_images = list(p.resolve() for p in Path(selected_folder).glob("**/*") if p.suffix in {".jpg", ".gif", ".png"}) + folder_name.config(text="Folder : " + selected_folder) + images_len.config(text="Found : " + str(len(found_images))) + + +title = Label(root, text="Drawing Training") +title.pack() + +folder_selector = Button(root, text="Select a folder", command=select_folder) +folder_selector.pack() + +folder_name = Label(root, text="Folder : " + selected_folder) +folder_name.pack() + +images_len = Label(root, text="Found : " + str(len(found_images))) +images_len.pack() + +timers = [30, 45, 60, 120, 300, 600] +buttons = [] +for i in timers: + t = i + new_button = Button(root, text=str(t) + "s", command=partial(set_timer_in_seconds, t)) + new_button.pack(side="left") + buttons.append(new_button) + +# timer_30 = Button(root, text="30s", command=lambda: set_timer_in_seconds(30)) +# timer_30.pack(side="left") +# +# timer_45 = Button(root, text="45s", command=lambda: set_timer_in_seconds(45)) +# timer_45.pack(side="left") +# +# timer_60 = Button(root, text="1m", command=lambda: set_timer_in_seconds(1 * 60)) +# timer_60.pack(side="left") +# +# timer_120 = Button(root, text="2m", command=lambda: set_timer_in_seconds(2 * 60)) +# timer_120.pack(side="left") +# +# timer_300 = Button(root, text="5m", command=lambda: set_timer_in_seconds(5 * 60)) +# timer_300.pack(side="left") +# +# timer_600 = Button(root, text="10m", command=lambda: set_timer_in_seconds(10 * 60)) +# timer_600.pack(side="left") + +launch_button = Button(root, text="Let's draw!") +launch_button.pack(side="bottom") + +root.mainloop()