[Tkinter-discuss] Menu.unpost not working on Windows?

Geoff Bache geoff.bache at gmail.com
Tue May 4 11:06:22 CEST 2010


Hi all,

I've been trying to use the "unpost" method on a popup menu and I
cannot make it work on Windows. It works fine on Linux, but seems to
have no effect on Windows even in simple cases. For example this basic
example code the menu is not unposted in Windows and is shown as
without the "unpost" line. Can anyone confirm or shed any light on
this?

Regards,
Geoff

from Tkinter import *

root = Tk()

w = Label(root, text="Right-click to display menu", width=40, height=20)
w.pack()

def next(*args):
    print "Next"

# create a menu
popup = Menu(root, tearoff=0)
popup.add_command(label="Next", command=next)

def do_popup(event):
    # display the popup menu
    popup.post(event.x_root, event.y_root)
    popup.unpost()

w.bind("<Button-3>", do_popup)

root.mainloop()


More information about the Tkinter-discuss mailing list