Popup menu won't hide on Linux

Coot dhein at acm.org
Sun Sep 15 16:20:46 EDT 2002

When a popup menu is displayed, I expect that it should goes away when
one of the menu items is clicked (button <1>) or when I click anywhere
else (such that the focus is no longer on the popup menu).

However, on Linux, the latter behavior doesn't happen.  The popup
remains on top of the main app window and the only way to get rid of
it is to click one of its menu command items or close the application.

This behavior isn't there on Windows.

Can anyone tell me how to solve, or work around, the problem???

Here is some example code you can use to demonstrate this problem for
yourself (taken from

# menu-example-4.py

from Tkinter import *

root = Tk()

def hello():
    print "hello!"

# create a popup menu
menu = Menu(root, tearoff=0)
menu.add_command(label="Undo", command=hello)
menu.add_command(label="Redo", command=hello)

# create a canvas
frame = Frame(root, width=512, height=512)

def popup(event):
    menu.post(event.x_root, event.y_root)

# attach popup to canvas
frame.bind("<Button-3>", popup)


More information about the Python-list mailing list