I have a problem in my project. In my program I have the availability to choose more files if I want. The Problem is, that the return choosen_files
has the list of the files but choosen_files which calls the more_files() method is none.
Do you have any suggestion?
Here is my code
import tkinter as tk
from tkinter import filedialog as fd
def get_files(path):
root = tk.Tk()
root.withdraw()
files = fd.askopenfilenames(
parent=root, title='Choose all files you want', initialdir=path)
return list(files)
def more_files(choosen_files, path):
print("choosen files:")
[print(file) for file in choosen_files]
wantMoreFiles = input(
"Do you want to choose more files? [(1) yes, (2) no]").lower()
if wantMoreFiles in ['1', 'y', 'yes']:
new_files = get_files(path)
choosen_files.extend(new_files)
more_files(choosen_files, path)
else:
return choosen_files
#this has the correct list
files = ['path/file1']
path = 'path'
choosen_files = more_files(files, path)
#this is none
Thank you very much!
CodePudding user response:
You don't return anything on the last line. Just return more_files(files, path)