Tkinter and popup menu

john.grayson at gsc.gte.com john.grayson at gsc.gte.com
Fri Aug 20 21:03:36 CEST 1999


john.grayso- at gsc.gte.com wrote: 
original article:http://www.egroups.com/group/python-list/?start=65387
> Hi.
> 
> I want a popup menu appear when clicking with the right button on a
> canvas
> (much like a contextual menu).
> 
> how to do this ?
> 
>     stef

Here is a little fragment showing popping up a menu from an
image in a label (canvas would be similar)...

...
    xxxdata.network = Toplevel(xxxdata.root)
    xxxdata.network.title('Network Planning & Engineering')
    iimg = PhotoImage(file='%s/%s' % (xxxdata.data.bitmaps,
'network.gif'))
    ilabel = Label(xxxdata.network, image=iimg)
    ilabel.pack()
    ilabel.bind('<Button-3>', doNETWORKMenu)

...
def doNETWORKMenu(event):
    pmenu = Menu(event.widget, tearoff=1)
    # Build a regular menu, as necessary
...
    pmenu.tk_popup(event.x, event.ypos)
...






More information about the Python-list mailing list