472,353 Members | 2,255 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 software developers and data experts.

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 3528
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Josh | last post by:
Caution, newbie approaching... I'm trying to come up with a very simple Tkinter test application that consists of a window with a drop-down menu...
3
by: Adonis | last post by:
I wish to create a popup menu from a list, when it is created they all show the same label from the list: Months = def _Menu_Click(self,...
0
by: Humpty Dumpty | last post by:
Hi folks, here's a challenge: I have a dynamically created cascading menu in Tkinter that can be quite large because it is created from a file. I...
0
by: Peter Otten | last post by:
How can I close a popup menu in Tkinter by clicking elsewhere on the toplevel window underneath? I tried popup.grab_set() but this causes the...
1
by: midtoad | last post by:
I'm trying to display a GIF image in a label as the central area to a Tkinter GUI. The image does not appear, though a space is made for it. Why...
0
by: mariox19 | last post by:
Hello, The Tkinter OptionMenu widget has me a bit confused. I have set up an OptionMenu to expand along the X axis as the window expands. What I...
2
by: ishtar2020 | last post by:
Hi everybody I'd appreciate some help on creating a tear off menu with TkInter. I've been reading some documentation but still no luck. Please...
3
by: joshdw4 | last post by:
I hate to do this, but I've thoroughly exhausted google search. Yes, it's that pesky root window and I have tried withdraw to no avail. I'm...
1
by: nihilium | last post by:
With a right click, a popup menu will appear, allowing to select from a list of colours. The queston is: is it necessary to create a callback...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.