Introduction to Programming using Python 1st Edition

Published by Pearson
ISBN 10: 0132747189
ISBN 13: 978-0-13274-718-9

Chapter 9 - GUI Programming using Tkinter - Section 9.11 - Mouse, Key Events, and Bindings - Check Point - MyProgrammingLab - Page 297: 9.31

Answer

The event for moving the mouse while pressing the right mouse button in Tkinter is represented by the string "". You can use this event string to bind a callback function to the right mouse button drag event on a widget.

Work Step by Step

import tkinter as tk def right_drag(event): print("Right mouse drag at", event.x, event.y) root = tk.Tk() canvas = tk.Canvas(root, width=300, height=200) canvas.pack() canvas.bind("", right_drag) root.mainloop() In this example, when the user moves the mouse while holding down the right mouse button, the right_drag function is called, which displays the mouse coordinates in the terminal. You can replace the right_drag function with your own custom code to handle the right mouse button drag event.
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.