You have two different file_list
variables in your code. One at global scope
file_list = ()
and one at function scope.
def choose_file(file_list):
With
file_list = fd.askopenfilenames()
you are assigning the list returned by askopenfilenames
to the function scope variable - everywhere in the function, file_list
will have the list from askopenfilenames
as value, what you can see by adding print(file_list)
to your function twice, one time at the beginning and one time at the end.
To modify the global variable instead of the local one, you can either make the local (function scope) variable global
file_list = ()
def choose_file():
global file_list
file_list = fd.askopenfilenames()
b1 = Button(command = choose_file)
where the variable initialization must be moved before the function declaration (I think else it gives an UnboundLocalError
or something), the lambda can be removed, and you do not need to pass file_list
as an argument.