Im trying to make a file edit programm and in it it will list the file and a button to go to the edit screen by picking from a list of files but it will only choose the last file in the list
I tried to make it a variable in the list but that wouldnt work and anything else i tried wouldnt work. heres the code
import tkinter as tk
root = tk.Tk()
root.geometry("400x400")
root.resizable(False, False)
def test(file):
print(file)
list = ["test.txt","test1.txt","test2.txt","test3.txt"]
for i in range(len(list)):
file = list[i]
print(file)
label = tk.Label(root, text=f"{file}")
button = tk.Button(root, command=lambda: test(file), text=f"{file}")
label.pack()
button.pack()
root.mainloop()