O'Reilly logo

Tkinter GUI Programming by Example by David Love

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

A floating menu

In order to place a Menu at a specific location we can use the place method. The place method takes two arguments: x and y. As the names imply these are coordinates of the exact location at which to draw the menu.

Since we will be binding this menu's creation to the right-click of a mouse, we will have access to an event object inside the bound function. It may seem intuitive, therefore, to just pass the x and y attributes of the event object to the place method and assume this will put the menu where the mouse was clicked.

The problem with this, however, is that the event object's coordinates are relative to the widget that  was bound, whereas the place system is relative to the user's screen. This means if the user is not ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required