Fix: Default config file dialog to repo root

Modified the get_file_path function in kohya_gui/common_gui.py
to ensure that when you are opening a configuration file, the
file dialog defaults to the kohya_ss repository root if no
initial path or only a filename is provided.

If a full or relative path is already present in the input field,
the dialog will open in the specified directory as before.

This change improves your experience by starting the file search
in a more relevant location.
pull/3265/head
google-labs-jules[bot] 2025-06-01 17:54:27 +00:00
parent 69d8b96c1c
commit 4ef34d9f5f
1 changed files with 5 additions and 3 deletions

View File

@ -492,9 +492,11 @@ def get_file_path(
if not any(var in os.environ for var in ENV_EXCLUSION) and sys.platform != "darwin": if not any(var in os.environ for var in ENV_EXCLUSION) and sys.platform != "darwin":
current_file_path = file_path # Backup in case no file is selected current_file_path = file_path # Backup in case no file is selected
initial_dir, initial_file = get_dir_and_file( if not os.path.dirname(file_path):
file_path initial_dir = scriptdir
) # Decompose file path for dialog setup else:
initial_dir = os.path.dirname(file_path)
initial_file = os.path.basename(file_path)
# Initialize a hidden Tkinter window for the file dialog # Initialize a hidden Tkinter window for the file dialog
root = Tk() root = Tk()