basic dnd catch
parent
2f67e2f159
commit
9746f78d45
|
@ -27,6 +27,8 @@ from modules.utilities import (
|
||||||
)
|
)
|
||||||
from modules.video_capture import VideoCapturer
|
from modules.video_capture import VideoCapturer
|
||||||
from modules.gettext import LanguageManager
|
from modules.gettext import LanguageManager
|
||||||
|
from tkinterdnd2 import DND_FILES, TkinterDnD
|
||||||
|
|
||||||
import platform
|
import platform
|
||||||
|
|
||||||
if platform.system() == "Windows":
|
if platform.system() == "Windows":
|
||||||
|
@ -143,7 +145,7 @@ def create_root(start: Callable[[], None], destroy: Callable[[], None]) -> ctk.C
|
||||||
ctk.set_appearance_mode("system")
|
ctk.set_appearance_mode("system")
|
||||||
ctk.set_default_color_theme(resolve_relative_path("ui.json"))
|
ctk.set_default_color_theme(resolve_relative_path("ui.json"))
|
||||||
|
|
||||||
root = ctk.CTk()
|
root = TkinterDnD.Tk()
|
||||||
root.minsize(ROOT_WIDTH, ROOT_HEIGHT)
|
root.minsize(ROOT_WIDTH, ROOT_HEIGHT)
|
||||||
root.title(
|
root.title(
|
||||||
f"{modules.metadata.name} {modules.metadata.version} {modules.metadata.edition}"
|
f"{modules.metadata.name} {modules.metadata.version} {modules.metadata.edition}"
|
||||||
|
@ -153,9 +155,13 @@ def create_root(start: Callable[[], None], destroy: Callable[[], None]) -> ctk.C
|
||||||
|
|
||||||
source_label = ctk.CTkLabel(root, text=None)
|
source_label = ctk.CTkLabel(root, text=None)
|
||||||
source_label.place(relx=0.1, rely=0.1, relwidth=0.3, relheight=0.25)
|
source_label.place(relx=0.1, rely=0.1, relwidth=0.3, relheight=0.25)
|
||||||
|
source_label.drop_target_register(DND_FILES)
|
||||||
|
source_label.dnd_bind('<<Drop>>', lambda e: print("SOURCE: ", e.data))
|
||||||
|
|
||||||
target_label = ctk.CTkLabel(root, text=None)
|
target_label = ctk.CTkLabel(root, text=None)
|
||||||
target_label.place(relx=0.6, rely=0.1, relwidth=0.3, relheight=0.25)
|
target_label.place(relx=0.6, rely=0.1, relwidth=0.3, relheight=0.25)
|
||||||
|
target_label.drop_target_register(DND_FILES)
|
||||||
|
target_label.dnd_bind('<<Drop>>', lambda e: print("TARGET: ", e.data))
|
||||||
|
|
||||||
select_face_button = ctk.CTkButton(
|
select_face_button = ctk.CTkButton(
|
||||||
root, text=_("Select a face"), cursor="hand2", command=lambda: select_source_path()
|
root, text=_("Select a face"), cursor="hand2", command=lambda: select_source_path()
|
||||||
|
@ -705,7 +711,7 @@ def fit_image_to_size(image, width: int, height: int):
|
||||||
ratio_h = height / h
|
ratio_h = height / h
|
||||||
# Use the smaller ratio to ensure the image fits within the given dimensions
|
# Use the smaller ratio to ensure the image fits within the given dimensions
|
||||||
ratio = min(ratio_w, ratio_h)
|
ratio = min(ratio_w, ratio_h)
|
||||||
|
|
||||||
# Compute new dimensions, ensuring they're at least 1 pixel
|
# Compute new dimensions, ensuring they're at least 1 pixel
|
||||||
new_width = max(1, int(ratio * w))
|
new_width = max(1, int(ratio * w))
|
||||||
new_height = max(1, int(ratio * h))
|
new_height = max(1, int(ratio * h))
|
||||||
|
|
Loading…
Reference in New Issue