commit fb091eca1d59437107d7e8bce9112512c5c87abd Author: Shikiryu Date: Sat May 20 02:33:19 2023 +0200 :sparkles: Hello world! diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6ef96ad --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +demo.py +first.py +theme.py +/.idea \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..a96f760 --- /dev/null +++ b/main.py @@ -0,0 +1,61 @@ +import dearpygui.dearpygui as dpg +from pathlib import Path + +dpg.create_context() + +selected_folder = "" +found_images = [] +timer = 0 + +with dpg.theme() as blue_theme: + with dpg.theme_component(dpg.mvAll): + dpg.add_theme_color(dpg.mvThemeCol_FrameBg, (0, 0, 200), category=dpg.mvThemeCat_Core) + + +def setTimerInSeconds(sender, app_data, user_data): + timer=user_data + print(sender) + print(dpg.get_item_theme(sender)) + dpg.bind_item_theme(sender, blue_theme) + print(dpg.get_item_theme(sender)) + + +def callback(sender, app_data): + selected_folder = app_data['file_path_name'] + found_images = list(p.resolve() for p in Path(selected_folder).glob("**/*") if p.suffix in {".jpg", ".gif", ".png"}) + dpg.set_value("folder_text", "Folder : " + selected_folder) + dpg.set_value("found_images_text", "Found : " + str(len(found_images))) + print('OK was clicked.') + print("Sender: ", sender) + print("App Data: ", app_data) + + +def cancel_callback(sender, app_data): + print('Cancel was clicked.') + print("Sender: ", sender) + print("App Data: ", app_data) + + +with dpg.file_dialog(directory_selector=True, show=False, callback=callback, tag="file_dialog_id", + cancel_callback=cancel_callback, width=700, height=400): + dpg.add_file_extension("Images (*.jpg *.gif *.png){.jpg,.gif,.png}", color=(0, 255, 255, 255)) + +with dpg.window(label="Drawing Training", width=300, height=800, pos=(0, 0), no_title_bar=True): + dpg.add_text("Drawing Training") + dpg.add_button(label="Select a folder", callback=lambda: dpg.show_item("file_dialog_id")) + dpg.add_text("Folder : " + selected_folder, tag="folder_text") + dpg.add_text("Found : " + str(len(found_images)), tag="found_images_text") + with dpg.group(horizontal=True): + dpg.add_button(label="30s", callback=setTimerInSeconds, user_data=30, tag="timer_30") + dpg.add_button(label="45s", callback=setTimerInSeconds, user_data=45, tag="timer_45") + dpg.add_button(label="1m", callback=setTimerInSeconds, user_data=1*60, tag="timer_60") + dpg.add_button(label="2m", callback=setTimerInSeconds, user_data=2*60, tag="timer_120") + dpg.add_button(label="5m", callback=setTimerInSeconds, user_data=5*60, tag="timer_300") + dpg.add_button(label="10m", callback=setTimerInSeconds, user_data=10*60, tag="timer_600") + dpg.add_button(label="Let's draw!") + +dpg.create_viewport(title='Drawing Training', width=300, height=600) +dpg.setup_dearpygui() +dpg.show_viewport() +dpg.start_dearpygui() +dpg.destroy_context() diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e9e3af0 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +dearpygui +pathlib \ No newline at end of file