New GitHub issue #100608 from Erriez:<br>
<hr>
<pre>
# Bug report
A submenu on a Treeview is not clickable. The screencapture demonstrates the problem:
`Copy | Selected` -> Not clickable
`Copy | All` -> Not clickable
`Paste` -> Works
![TkinterTreeviewSubmenu](https://user-images.githubusercontent.com/8849873/210007555-c369012f-1bf1-47b1-8e66-b36c077874b7.gif)
Test code:
```python
from tkinter import *
from tkinter import ttk
class App(Tk):
def __init__(self, *args, **kwargs):
Tk.__init__(self, *args, **kwargs)
# Create menu
self.tree_menu = Menu(self, tearoff=0)
# Create Copy submenu Selected and All (Not working)
self.table_submenu_copy = Menu(self, tearoff=0)
self.tree_menu.add_cascade(label="Copy", menu=self.table_submenu_copy)
self.table_submenu_copy.add_command(label="Selected", command=self.copy_selected)
self.table_submenu_copy.add_command(label="All", command=self.copy_all)
# Create normal menu (Works)
self.tree_menu.add_command(label="Paste", command=self.paste)
# Create Treeview
tree_scroll = ttk.Scrollbar(self)
tree_scroll.pack(side=RIGHT, fill=Y)
columns = ['first_name', 'last_name', 'age']
self.tree = ttk.Treeview(self, columns=columns, show="headings")
self.tree.pack(side=LEFT, fill=BOTH)
self.tree.heading("first_name", text="First Name")
self.tree.heading("last_name", text="Last Name")
self.tree.heading("age", text="Age")
# Insert values
self.tree.insert('', END, values=("Piet", "Hendriks", 23))
self.tree.insert('', END, values=("Jan", "van Veen", 46))
self.tree.insert('', END, values=("Karin", "Dijkstra", 55))
self.tree.insert('', END, values=("Sonja", "Bakker", 16))
self.tree.insert('', END, values=("Kees", "Visser", 89))
# Right mouseclick
self.tree.bind("<Button-3>", self.do_popup)
def do_popup(self, event):
# display the popup menu
try:
self.tree_menu.selection = self.tree.set(self.tree.identify_row(event.y))
self.tree_menu.post(event.x_root, event.y_root)
finally:
# make sure to release the grab (Tk 8.0a1 only)
self.tree_menu.grab_release()
def copy_selected(self):
print('Copy selected:', self.tree.selection())
def copy_all(self):
print('Copy all:', self.tree.selection())
def paste(self):
print('Paste')
def main():
root = App()
root.mainloop()
if __name__ == '__main__':
main()
```
# Your environment
- CPython versions tested on: 3.10.6
- Operating system and architecture: Ubuntu 22.04
Any suggestion how to fix this?
</pre>
<hr>
<a href="https://github.com/python/cpython/issues/100608">View on GitHub</a>
<p>Labels: type-bug</p>
<p>Assignee: </p>