Add drag and drop for source and target

This commit is contained in:
henryruhs 2023-07-19 10:29:25 +02:00
parent b34321416c
commit 5cfa5a1cfa
5 changed files with 21 additions and 4 deletions

View File

@ -5,6 +5,7 @@ insightface==0.7.3
psutil==5.9.5
tk==0.1.0
customtkinter==5.2.0
tkinterdnd2==0.3.0
torch==2.0.1
torchvision==0.15.2
onnxruntime==1.15.0

View File

@ -7,6 +7,7 @@ insightface==0.7.3
psutil==5.9.5
tk==0.1.0
customtkinter==5.2.0
tkinterdnd2==0.3.0
pillow==10.0.0
torch==2.0.1+cu118; sys_platform != 'darwin'
torch==2.0.1; sys_platform == 'darwin'

View File

@ -22,7 +22,7 @@ def get_face_enhancer() -> Any:
with THREAD_LOCK:
if FACE_ENHANCER is None:
model_path = resolve_relative_path('../models/GFPGANv1.4.pth')
# todo: set models path https://github.com/TencentARC/GFPGAN/issues/399
# todo: set models path -> https://github.com/TencentARC/GFPGAN/issues/399
FACE_ENHANCER = GFPGANer(model_path=model_path, upscale=1, device=get_device())
return FACE_ENHANCER

View File

@ -152,6 +152,9 @@
"weight": "normal"
}
},
"RoopDropArea": {
"fg_color": ["gray90", "gray13"]
},
"RoopDonate": {
"text_color": ["#3a7ebf", "gray60"]
}

View File

@ -2,6 +2,7 @@ import os
import sys
import webbrowser
import customtkinter as ctk
from tkinterdnd2 import TkinterDnD, DND_ALL
from typing import Callable, Tuple, Optional
import cv2
from PIL import Image, ImageOps
@ -34,6 +35,13 @@ target_label = None
status_label = None
# todo: remove by native support -> https://github.com/TomSchimansky/CustomTkinter/issues/934
class CTk(ctk.CTk, TkinterDnD.DnDWrapper):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.TkdndVersion = TkinterDnD._require(self)
def init(start: Callable[[], None], destroy: Callable[[], None]) -> ctk.CTk:
global ROOT, PREVIEW
@ -50,19 +58,23 @@ def create_root(start: Callable[[], None], destroy: Callable[[], None]) -> ctk.C
ctk.set_appearance_mode('system')
ctk.set_default_color_theme(resolve_relative_path('ui.json'))
root = ctk.CTk()
root = CTk()
root.minsize(ROOT_WIDTH, ROOT_HEIGHT)
root.title(f'{roop.metadata.name} {roop.metadata.version}')
root.configure()
root.protocol('WM_DELETE_WINDOW', lambda: destroy())
source_label = ctk.CTkLabel(root, text=None)
source_label = ctk.CTkLabel(root, text=None, fg_color=ctk.ThemeManager.theme.get('RoopDropArea').get('fg_color'))
source_label.place(relx=0.1, rely=0.1, relwidth=0.3, relheight=0.25)
source_label.drop_target_register(DND_ALL)
source_label.dnd_bind('<<Drop>>', lambda event: select_source_path(event.data))
if roop.globals.source_path:
select_source_path(roop.globals.source_path)
target_label = ctk.CTkLabel(root, text=None)
target_label = ctk.CTkLabel(root, text=None, fg_color=ctk.ThemeManager.theme.get('RoopDropArea').get('fg_color'))
target_label.place(relx=0.6, rely=0.1, relwidth=0.3, relheight=0.25)
target_label.drop_target_register(DND_ALL)
target_label.dnd_bind('<<Drop>>', lambda event: select_target_path(event.data))
if roop.globals.target_path:
select_target_path(roop.globals.target_path)