def generate_menu(self):
self.some_menu = tk.Menu(self.menubar, tearoff=0)
self.menubar.add_cascade(label="Some Label", menu=self.some_menu)
some_directory = SCRIPT_ROOT + "/" + SOME_FOLDER
for filename in os.listdir(some_directory):
test_file = (test_directory + "/" + filename)
print(test_file)
self.some_menu.add_command(label=filename, command=lambda: self.files.add_files(test_file))
This code generates a menu item with a dropdown containing:
- File 1
- File 2
- File 3
and so on.
Each file option should have an individual command calling the same function but with a different argument.
self.files.add_files(<argument should be based on iteration of for loop)
What is happening is that each file option is actually using the command for File 3 (or the last file on the dropdown).
There is a fault in logic somewhere - can you spot it?