Compare commits
2 Commits
main
...
models_onl
Author | SHA1 | Date | |
---|---|---|---|
312f481eb3 | |||
|
7ba8d55252 |
@ -4,3 +4,5 @@ pygame~=2.4.0
|
|||||||
customtkinter~=5.1.3
|
customtkinter~=5.1.3
|
||||||
configparser~=5.3.0
|
configparser~=5.3.0
|
||||||
CTkToolTip~=0.4
|
CTkToolTip~=0.4
|
||||||
|
requests~=2.32.3
|
||||||
|
CTkMenuBar~=0.8
|
41
src/entity/generator.py
Normal file
41
src/entity/generator.py
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
from datetime import datetime
|
||||||
|
import os
|
||||||
|
import io
|
||||||
|
import tempfile
|
||||||
|
import requests
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
|
|
||||||
|
class Generator(object):
|
||||||
|
|
||||||
|
def __init__(self, generator=None, folder=None):
|
||||||
|
self.selected_folder = folder
|
||||||
|
if generator == 'poses':
|
||||||
|
self.generate_poses()
|
||||||
|
|
||||||
|
def generate_poses(self):
|
||||||
|
dt = datetime.now()
|
||||||
|
ts = int(datetime.timestamp(dt))
|
||||||
|
url = 'https://quickposes.com/ajax/getPosesForSlider/Chiaroscuro?_=' + str(ts)
|
||||||
|
|
||||||
|
resp_json = requests.get(url=url)
|
||||||
|
if resp_json.status_code == 200:
|
||||||
|
data = resp_json.json()
|
||||||
|
c = 0
|
||||||
|
for src in data:
|
||||||
|
if os.path.exists(os.path.join(self.selected_folder, src['src'])):
|
||||||
|
continue
|
||||||
|
if c >= 3:
|
||||||
|
break
|
||||||
|
buffer = tempfile.SpooledTemporaryFile(max_size=1e9)
|
||||||
|
r = requests.get('https://quickposes.com/assets/poses/' + src['src'], stream=True)
|
||||||
|
if r.status_code == 200:
|
||||||
|
downloaded = 0
|
||||||
|
for chunk in r.iter_content(chunk_size=1024):
|
||||||
|
downloaded += len(chunk)
|
||||||
|
buffer.write(chunk)
|
||||||
|
buffer.seek(0)
|
||||||
|
i = Image.open(io.BytesIO(buffer.read()))
|
||||||
|
i.save(os.path.join(self.selected_folder, src['src']), quality=85)
|
||||||
|
buffer.close()
|
||||||
|
c += 1
|
30
src/window/about.py
Normal file
30
src/window/about.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import webbrowser
|
||||||
|
|
||||||
|
import customtkinter
|
||||||
|
from customtkinter import CTkToplevel
|
||||||
|
|
||||||
|
|
||||||
|
class AboutWindow:
|
||||||
|
def __init__(self, app):
|
||||||
|
self.app = app
|
||||||
|
|
||||||
|
self.window = CTkToplevel(app.root)
|
||||||
|
self.window.title("À propos")
|
||||||
|
self.window.geometry("600x300")
|
||||||
|
self.window.protocol("WM_DELETE_WINDOW", self.on_closing)
|
||||||
|
|
||||||
|
link_gesture_drawing = customtkinter.CTkLabel(self.window, text="Open Source alternative to GestureDrawing!")
|
||||||
|
link_gesture_drawing.pack()
|
||||||
|
link_gesture_drawing.bind("<Button-1>",
|
||||||
|
lambda e: self.open_link("https://cubebrush.co/advanches/products/d9q6yq/gesturedrawing"))
|
||||||
|
|
||||||
|
link_shikiryu = customtkinter.CTkLabel(self.window, text="by Shikiryu")
|
||||||
|
link_shikiryu.pack()
|
||||||
|
link_shikiryu.bind("<Button-1>", lambda e: self.open_link("https://shikiryu.com"))
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def open_link(url):
|
||||||
|
webbrowser.open_new(url)
|
||||||
|
|
||||||
|
def on_closing(self):
|
||||||
|
self.window.destroy()
|
@ -4,9 +4,12 @@ from tkinter import *
|
|||||||
from tkinter import filedialog
|
from tkinter import filedialog
|
||||||
import customtkinter
|
import customtkinter
|
||||||
from src.entity.config import Config
|
from src.entity.config import Config
|
||||||
|
from src.entity.generator import Generator
|
||||||
from src.util import Util
|
from src.util import Util
|
||||||
|
from src.window.about import AboutWindow
|
||||||
from src.window.image import ImageWindow
|
from src.window.image import ImageWindow
|
||||||
from src.window.session import SessionWindow
|
from src.window.session import SessionWindow
|
||||||
|
from CTkMenuBar import *
|
||||||
|
|
||||||
|
|
||||||
class App:
|
class App:
|
||||||
@ -22,6 +25,17 @@ class App:
|
|||||||
self.selected_folder = ""
|
self.selected_folder = ""
|
||||||
self.found_images = []
|
self.found_images = []
|
||||||
self.timer = 0
|
self.timer = 0
|
||||||
|
|
||||||
|
menu = CTkMenuBar(master=root)
|
||||||
|
generate_button = menu.add_cascade("Generate")
|
||||||
|
help_button = menu.add_cascade("Help")
|
||||||
|
|
||||||
|
dropdown = CustomDropdownMenu(widget=generate_button)
|
||||||
|
dropdown.add_option(option="Poses", command=lambda:self.download_poses('poses'))
|
||||||
|
|
||||||
|
about = CustomDropdownMenu(widget=help_button)
|
||||||
|
about.add_option(option="À propos", command=self.show_help)
|
||||||
|
|
||||||
self.title = customtkinter.CTkLabel(root, text="Drawing Training")
|
self.title = customtkinter.CTkLabel(root, text="Drawing Training")
|
||||||
self.title.pack()
|
self.title.pack()
|
||||||
|
|
||||||
@ -49,7 +63,8 @@ class App:
|
|||||||
|
|
||||||
self.buttons = []
|
self.buttons = []
|
||||||
for i, timer in enumerate(timers):
|
for i, timer in enumerate(timers):
|
||||||
new_button = customtkinter.CTkButton(self.button_frame, width=10, text=timer, command=lambda t=timer: self.set_timer_in_seconds(t))
|
new_button = customtkinter.CTkButton(self.button_frame, width=10, text=timer,
|
||||||
|
command=lambda t=timer: self.set_timer_in_seconds(t))
|
||||||
new_button.pack(side=tkinter.LEFT, fill=X, expand=True)
|
new_button.pack(side=tkinter.LEFT, fill=X, expand=True)
|
||||||
self.buttons.append(new_button)
|
self.buttons.append(new_button)
|
||||||
|
|
||||||
@ -66,6 +81,9 @@ class App:
|
|||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def show_help(self):
|
||||||
|
AboutWindow(self)
|
||||||
|
|
||||||
def lets_draw(self):
|
def lets_draw(self):
|
||||||
self.image_window = ImageWindow(self)
|
self.image_window = ImageWindow(self)
|
||||||
self.image_window.lets_draw(self.found_images.copy(), self.timer)
|
self.image_window.lets_draw(self.found_images.copy(), self.timer)
|
||||||
@ -83,6 +101,10 @@ class App:
|
|||||||
self.find_images_in_folder()
|
self.find_images_in_folder()
|
||||||
self.check_lets_draw()
|
self.check_lets_draw()
|
||||||
|
|
||||||
|
def download_poses(self, generator=None):
|
||||||
|
Generator(generator=generator, folder=self.selected_folder)
|
||||||
|
self.find_images_in_folder()
|
||||||
|
|
||||||
def find_images_in_folder(self):
|
def find_images_in_folder(self):
|
||||||
if Path(self.selected_folder).exists():
|
if Path(self.selected_folder).exists():
|
||||||
self.found_images = list(
|
self.found_images = list(
|
||||||
@ -99,7 +121,8 @@ class App:
|
|||||||
def set_timer_in_seconds(self, user_data):
|
def set_timer_in_seconds(self, user_data):
|
||||||
# resetting buttons states
|
# resetting buttons states
|
||||||
for button in self.buttons:
|
for button in self.buttons:
|
||||||
button.configure(fg_color=(Util.get_default_button_color() if user_data != button.cget("text") else Util.get_default_active_button_color()))
|
button.configure(fg_color=(Util.get_default_button_color() if user_data != button.cget(
|
||||||
|
"text") else Util.get_default_active_button_color()))
|
||||||
|
|
||||||
self.custom = False
|
self.custom = False
|
||||||
if user_data == "Custom":
|
if user_data == "Custom":
|
||||||
|
Loading…
Reference in New Issue
Block a user