469,954 Members | 1,657 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,954 developers. It's quick & easy.

Re: Tkinter popup menu

"Chuckk Hubbard" <ba*************@gmail.comwrites:
Right-click popup menu. None of the options that come from the
cascades can be selected with the mouse. If you select a submenu with
the mouse and then use the arrow keys and enter key to select an
option, it works, but the menu remains on the canvas. If you click
the option with the mouse, the menu disappears but the function
doesn't get called.
Can someone tell me why?

-Chuckk

--
http://www.badmuthahubbard.com
Try creating the "main" popup menu before the sub-menus, and when
instantiating the sub-menus, pass the main menu as the "master"
instead of "self.myparent":

....snip code -----------------------------------------
self.canvas.bind("<Button-3>",self.popup)

self.menupopup = tk.Menu(self.myparent, tearoff=0)

self.menupopup1 = tk.Menu(self.menupopup, tearoff=0)
self.menupopup1.add_command(label="Test1", command=self.selected)
self.menupopup1.add_command(label="Test2", command=self.selected)
self.menupopup1.add_command(label="Test3", command=self.selected)
self.menupopup2 = tk.Menu(self.menupopup, tearoff=0)
self.menupopup2.add_command(label="Test1", command=self.selected)
self.menupopup2.add_command(label="Test2", command=self.selected)
self.menupopup2.add_command(label="Test3", command=self.selected)

# self.menupopup = tk.Menu(self.myparent, tearoff=0)
self.menupopup.add_cascade(label="Test1", menu=self.menupopup1)
self.menupopup.add_cascade(label="Test2", menu=self.menupopup2)
....end code changes ----------------------------------

Hope that helps.
Carl.
Aug 28 '08 #1
1 3391
On Thu, Aug 28, 2008 at 3:50 AM, Carl <c.******@gmail.comwrote:
"Chuckk Hubbard" <ba*************@gmail.comwrites:
>Right-click popup menu. None of the options that come from the
cascades can be selected with the mouse. If you select a submenu with
the mouse and then use the arrow keys and enter key to select an
option, it works, but the menu remains on the canvas. If you click
the option with the mouse, the menu disappears but the function
doesn't get called.
Can someone tell me why?

-Chuckk

--
http://www.badmuthahubbard.com

Try creating the "main" popup menu before the sub-menus, and when
instantiating the sub-menus, pass the main menu as the "master"
instead of "self.myparent":
Thanks Carl, that indeed did it.
-Chuckk
>
Hope that helps.
Carl.
--
http://mail.python.org/mailman/listinfo/python-list


--
http://www.badmuthahubbard.com
Sep 3 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Adonis | last post: by
reply views Thread by Humpty Dumpty | last post: by
reply views Thread by Peter Otten | last post: by
reply views Thread by mariox19 | last post: by
3 posts views Thread by joshdw4 | last post: by
1 post views Thread by nihilium | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.