I have a TKinter dropdown menu created with this code:
#menu
menu = Menu(window)
window.config(menu = menu)
subMenu = Menu(menu)
menu.add_cascade(label = "Kies een ander station", menu = subMenu)
subMenu.add_command(label = "Amersfoort", command = print('test'))
subMenu.add_separator()
subMenu.add_command(label = "Amsterdam Centraal", command = print('test2'))
subMenu.add_separator()
#etc..
When I compile and run, the code in the command
attribute of each subMenu.add_command()
function is being executed right away. I want to achieve this when I click on a menu item. How do I do that?