zentk - folder select workaround (#1478)

* zentk - folder select workaround

* kcppt extention fix
This commit is contained in:
henk717 2025-04-11 16:37:07 +02:00 committed by GitHub
parent 8fd70f37bd
commit f6b7fea979
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3528,7 +3528,11 @@ def zenity(typ, filetypes=None, initialdir="", initialfile="", **kwargs) -> Tupl
def zentk_askopenfilename(**options): def zentk_askopenfilename(**options):
try: try:
from os.path import isfile
result = zenity('file-selection', filetypes=options.get("filetypes"), initialdir=options.get("initialdir"), title=options.get("title"))[1] result = zenity('file-selection', filetypes=options.get("filetypes"), initialdir=options.get("initialdir"), title=options.get("title"))[1]
if result and not isfile(result):
print("A folder was selected while we need a file, ignoring selection.")
return ''
except: except:
from tkinter.filedialog import askopenfilename from tkinter.filedialog import askopenfilename
result = askopenfilename(**options) result = askopenfilename(**options)
@ -4420,7 +4424,7 @@ def show_gui():
return return
filenamestr = str(filename).strip() filenamestr = str(filename).strip()
if not filenamestr.endswith(".kcppt"): if not filenamestr.endswith(".kcppt"):
filenamestr += ".kcpps" filenamestr += ".kcppt"
file = open(filenamestr, 'w') file = open(filenamestr, 'w')
file.write(json.dumps(savdict)) file.write(json.dumps(savdict))
file.close() file.close()