Skip to Content
Tkinter GUI Programming by Example
book

Tkinter GUI Programming by Example

by David Love
April 2018
Beginner content levelBeginner
340 pages
7h 54m
English
Packt Publishing
Content preview from Tkinter GUI Programming by Example

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.
Start your free trial

You might also like

Tkinter GUI Application Development Blueprints, Second Edition - Second Edition

Tkinter GUI Application Development Blueprints, Second Edition - Second Edition

Bhaskar Chaudhary

Publisher Resources

ISBN: 9781788627481Supplemental Content