[Tkinter-discuss] pop up menu down
Martin Franklin
mfranklin1 at gatwick.westerngeco.slb.com
Tue Sep 20 09:58:03 CEST 2005
Stewart Midwinter wrote:
> this might not be what you want, but you could include a menu-item
> "Close Menu" in your pop-up menu, which would destroy (close) the pop-
> up menu...
>
> S
>
>
>
> On Sep 19, 2005, at 22:41, Monu Agrawal wrote:
>
>
>>Hi,
>>I have a pop up menu used to pop at right click, but the problem is
>>it doesn't go away until I click on one of it's button. I want it
>>to be disappeared or destroyed when I click anywhere else. Can
>>anyone tell me what I am missing?
>>_______________________________________________
>>Tkinter-discuss mailing list
>>Tkinter-discuss at python.org
>>http://mail.python.org/mailman/listinfo/tkinter-discuss
>>
Strange on my box (fedora core 4) is doesn't stay poped up so if I
release mouse button 3 it disappears. Perhaps it is a platorm issue?
my popup code is below:-
class PopupMenu:
def __init__(self, parent):
self.parent = parent
self.menu=Menu(None,tearoff=0)
def __call__(self, event):
self.menu.tk_popup(event.x_root ,event.y_root)
def add_separator(self):
self.menu.add_separator()
def add(self, text, command):
self.menu.add_command(label=text, command=command)
add_command = add
and when I use it :-
fileMenu = PopupMenu(self)
fileMenu.add_command("Create New File", command=self.createFile)
self.fileList.body_bind("<3>", fileMenu)
HTH
Martin
More information about the Tkinter-discuss
mailing list