hacksider / Deep-Live-Cam

real time face swap and one-click video deepfake with only a single image
GNU Affero General Public License v3.0
34.93k stars 4.93k forks source link

Allow Drag-and-Drop of Source and Target Files #368

Open justin-m-lacy opened 4 weeks ago

justin-m-lacy commented 4 weeks ago

Commit adds library tkinterdnd2 to enable dragging and dropping of source and target files from the file explorer.

Note that on Visual Studio Code, drag and drop may be blocked if VSCode was installed per-user, instead of for all users.

I am not a python programmer, but have tested this myself on Windows 10, and it works.

It may be you don't want to use the additional tkinter library in which case you can ignore.

Summary by Sourcery

Integrate drag-and-drop functionality for source and target files in the UI by using the tkinterdnd2 library. Refactor the UI initialization to support this feature, allowing users to drag files directly from the file explorer into the application.

New Features:

Enhancements:

sourcery-ai[bot] commented 4 weeks ago

Reviewer's Guide by Sourcery

This pull request implements drag-and-drop functionality for source and target files in the user interface. It uses the tkinterdnd2 library to enable this feature. The changes primarily affect the ui.py file, modifying the root window creation and adding event handlers for drag-and-drop operations.

File-Level Changes

Files Changes
modules/ui.py Created a new class CTk that inherits from both ctk.CTk and TkinterDnD.DnDWrapper to enable drag-and-drop functionality
modules/ui.py Modified the create_root function to use the new CTk class instead of ctk.CTk
modules/ui.py Added drag-and-drop event bindings to source and target labels and buttons
modules/ui.py Implemented drop_source_file and drop_target_file functions to handle dropped files
modules/ui.py Refactored select_source_path and select_target_path functions to use new set_source_path and set_target_path functions
modules/ui.py Implemented set_source_path and set_target_path functions to handle both manual selection and drag-and-drop

Tips - Trigger a new Sourcery review by commenting `@sourcery-ai review` on the pull request. - Continue your discussion with Sourcery by replying directly to review comments. - You can change your review settings at any time by accessing your [dashboard](https://app.sourcery.ai): - Enable or disable the Sourcery-generated pull request summary or reviewer's guide; - Change the review language; - You can always [contact us](mailto:support@sourcery.ai) if you have any questions or feedback.