Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python with Tk: rightclick menu window not showing #112

Closed
JeroenValkonet opened this issue Apr 21, 2015 · 2 comments
Closed

Python with Tk: rightclick menu window not showing #112

JeroenValkonet opened this issue Apr 21, 2015 · 2 comments

Comments

@JeroenValkonet
Copy link

A python (2.79) demo code snippet that pops up a menu dialog on right-clicking with the mouse works OK in cmd.exe (Windows7 64 bit) but when started from ConEmu the popup menu does not show.

See below for the snippet or get it from here:
http://stackoverflow.com/questions/12014210/python-tkinter-app-adding-a-right-click-context-menu
(i actually found this bug using a much larger python application but for bug-hunting this snippet is enough).

If i look closely it could be that the menu appears for a split second but is immediately closed.

I also noticed that when started from cmd.exe the parent window maintains focus upon right-click (as the popup menu appears).
But when started from ConEmu the parent window looses focus upon right-click.

Code snippet:

from Tkinter import * # Tkinter -> tkinter in Python 3

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 frame
frame = Frame(root, width=512, height=512)
frame.pack()

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

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

root.mainloop()
@Maximus5
Copy link
Owner

@JeroenValkonet
Copy link
Author

Yes, this patch fixed it. I tested with both the python code snippet as well as the Python application that led to this reported issue.
Thank you for your quick response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants