Fixed selector2list
@@ -441,19 +441,10 @@ def nextfolder_to_list(ifolder,extlist=['nsp'],filter=False,alfanumeric=False):
nutPrint.error('Exception: ' + str(e))
return filelist
-
-
def selector2list(textfile,mode='folder',ext=False,filter=False,Print=False):
root = tk.Tk()
root.withdraw()
root.wm_attributes('-topmost', 1)
- if mode=='file':
- filepath = filedialog.askopenfilename()
- filelist=[]
- filelist.append(filepath)
- return filelist
- else:
- filepath = filedialog.askdirectory()
extlist=list()
if ext!=False:
if isinstance(ext, list):
@@ -473,7 +464,19 @@ def selector2list(textfile,mode='folder',ext=False,filter=False,Print=False):
extlist.append(ext)
else:
extlist=['nsp','xci','nsx','xcz','nsz']
-
+ if mode=='file':
+ filetypes=[]
+ for x in extlist:
+ if not x.startswith('.'):
+ x='.'+x
+ entry=("Filetypes",f"*{x}")
+ filetypes.append(entry)
+ filepath = filedialog.askopenfilename(filetypes=filetypes)
+ filelist=[]
+ filelist.append(filepath)
+ else:
+ filepath = filedialog.askdirectory()
+ if mode!='file':
ruta=filepath
filelist=list()
try:
@@ -530,15 +533,15 @@ def selector2list(textfile,mode='folder',ext=False,filter=False,Print=False):
if fname != "":
if binbin.lower() not in filename.lower():
filelist.append(filename)
-
+ except BaseException as e:
+ nutPrint.error('Exception: ' + str(e))
+ if filelist:
with open(textfile,"a", encoding='utf8') as tfile:
for line in filelist:
try:
tfile.write(line+"\n")
except:
continue
- except BaseException as e:
- nutPrint.error('Exception: ' + str(e))
return filelist
def size_sorted_from_json(jsonfile,tfile,first='small'):
