Menu total index counts, length of menu items Menu total index counts, length of menu items tkinter tkinter

Menu total index counts, length of menu items


You can use self.commandMenu.index("end") to get the index of the last item in the menu. You can then iterate over the items to configure them all:

last = self.commandMenu.index("end")for i in range(last+1):    self.commandMenu.entryconfigure(i, state="normal")


[Updating the answer of Bryan Oakley]

self.commandMenu.index("end") won't work.
Use self.commandMenu.index(tk.END) instead.

[EDIT]Make sure to catch error when the menu has no element : index(tk.END) will return None and you will have an error Cannot add int and NoneType.