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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access