✨ Hello world!
This commit is contained in:
commit
fb091eca1d
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
demo.py
|
||||
first.py
|
||||
theme.py
|
||||
/.idea
|
61
main.py
Normal file
61
main.py
Normal file
@ -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()
|
2
requirements.txt
Normal file
2
requirements.txt
Normal file
@ -0,0 +1,2 @@
|
||||
dearpygui
|
||||
pathlib
|
Loading…
Reference in New Issue
Block a user