473,385 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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 3608
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 bar at the top and a grid of colored rectangles...
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, month): print month menu = Menu(fraMain, tearoff=0)
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 tried using lazy creation so only the menu item...
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 popup to close immediately. An alternative would...
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 is this so? I notice that I can display a GIF...
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 find though is that the width of the submenu...
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 don't get confused: when I mean "tear off" menu I...
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 assuming this is because of the methods I'm using. I...
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 function for each colour? How may I pass on information...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.