Get label value from dynamically created menu items [tkinter]
I have a cascade menu in a parent menu. The cascade items are created dynamically with add_checkbutton
method.
A user should be able to "check" menu items and select/confirm them. However, I don't know how to access text in the menu items, to decide which item is selected.
Obvious solution is开发者_开发百科 to generate tk.StringVar
dynamically, but I would like to avoid that since it complicates the code significantly.
How to get value of the menu label/text in tkinter? Is there other solution to the problem?
You can use the entrycget method of a menu item to get any of its attributes, including the label and value.
精彩评论