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

Comments

Projects
None yet
2 participants
@JeroenValkonet

JeroenValkonet commented Apr 21, 2015

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

This comment has been minimized.

@JeroenValkonet

This comment has been minimized.

JeroenValkonet commented Apr 22, 2015

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