From 4ef34d9f5f302fdff07d7ad0b73465fe755a83aa Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 1 Jun 2025 17:54:27 +0000 Subject: [PATCH] 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. --- kohya_gui/common_gui.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/kohya_gui/common_gui.py b/kohya_gui/common_gui.py index 8823cb7..f55a618 100644 --- a/kohya_gui/common_gui.py +++ b/kohya_gui/common_gui.py @@ -492,9 +492,11 @@ def get_file_path( 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 - initial_dir, initial_file = get_dir_and_file( - file_path - ) # Decompose file path for dialog setup + if not os.path.dirname(file_path): + initial_dir = scriptdir + else: + initial_dir = os.path.dirname(file_path) + initial_file = os.path.basename(file_path) # Initialize a hidden Tkinter window for the file dialog root = Tk()