Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented native filepicker for file/folder operations #1368

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions UVR.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@
from ml_collections import ConfigDict
from collections import Counter

try:
from plyer import filechooser
is_native_filepicker = True
except ModuleNotFoundError:
is_native_filepicker = False
pass

# if not is_macos:
# import torch_directml

Expand Down Expand Up @@ -964,7 +971,7 @@ def create_label_config():

# Create the actual tooltip
self.tooltip = tk.Toplevel(self.widget)
self.tooltip.wm_overrideredirect(True)
self.tooltip.wm_attributes('-type', 'splash')
self.tooltip.wm_geometry(f"+{x}+{y}")

label_config = create_label_config()
Expand Down Expand Up @@ -2144,6 +2151,25 @@ def linux_filebox_fix(self, is_on=True):
gui_data.sv_ttk.set_theme("dark", MAIN_FONT_NAME, 10, fg_color_set=fg_color_set)

def show_file_dialog(self, text='Select Audio files', dialoge_type=None):
if is_native_filepicker:
if dialoge_type == MULTIPLE_FILE:
filenames = filechooser.open_file(title=text, multiple=True)
elif dialoge_type == MAIN_MULTIPLE_FILE:
filenames = filechooser.open_file(title=text, path=self.lastDir, multiple=True)
elif dialoge_type == SINGLE_FILE:
filenames = filechooser.open_file(title=text)
elif dialoge_type == CHOOSE_EXPORT_FIR:
filenames = filechooser.choose_dir(title=f'Select Folder')
if filenames is not None:
return filenames[0]
else:
return None

if filenames is not None:
return tuple(filenames)
else:
return None

parent_win = root
is_linux = not is_windows and not is_macos

Expand Down Expand Up @@ -2171,7 +2197,6 @@ def show_file_dialog(self, text='Select Audio files', dialoge_type=None):
title=f'Select Folder',)

if is_linux:
print("Is Linux")
self.linux_filebox_fix(False)
top.destroy()

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ SoundFile==0.11.0; sys_platform != 'darwin'
PySoundFile==0.9.0.post1; sys_platform == 'darwin'
Dora==0.0.3
numpy==1.23.5
plyer==2.1.0