Skip to content

Commit 4dd1c2b

Browse files
Improve launcher file dialog initial paths (ggml-org#740)
- In the launcher, if an existing value is set for a file value (e.g. Model), use that file's directory the initial directory when the file dialog is opened with 'Browse'. - In the launcher always set the intial directory for 'Load' to cwd.
1 parent 95c8090 commit 4dd1c2b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

koboldcpp.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1573,7 +1573,9 @@ def makelabelentry(parent, text, var, row=0, width= 50,tooltip=""):
15731573
def makefileentry(parent, text, searchtext, var, row=0, width=200, filetypes=[], onchoosefile=None, singlerow=False, tooltiptxt=""):
15741574
makelabel(parent, text, row,0,tooltiptxt)
15751575
def getfilename(var, text):
1576-
fnam = askopenfilename(title=text,filetypes=filetypes)
1576+
initialDir = os.path.dirname(var.get())
1577+
initialDir = initialDir if os.path.isdir(initialDir) else os.getcwd()
1578+
fnam = askopenfilename(title=text,filetypes=filetypes, initialdir=initialDir)
15771579
if fnam:
15781580
var.set(fnam)
15791581
if onchoosefile:
@@ -2230,7 +2232,7 @@ def load_config():
22302232
file_type = [("KoboldCpp Settings", "*.kcpps")]
22312233
global runmode_untouched
22322234
runmode_untouched = False
2233-
filename = askopenfilename(filetypes=file_type, defaultextension=file_type)
2235+
filename = askopenfilename(filetypes=file_type, defaultextension=file_type, initialdir=os.getcwd())
22342236
if not filename or filename=="":
22352237
return
22362238
with open(filename, 'r') as f:

0 commit comments

Comments
 (0)