Introduction to Programming using Python 1st Edition

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

Chapter 11 - Multidimensional Lists - Programming Exercises - Page 397: 11.48

Answer

Here's an example (provided in the step by step procedure) of a program that implements the functionality as described in the problem using the Tkinter library: (left click: adds ball, right click on ball: removes that ball)

Work Step by Step

import tkinter as tk def add_point(event): x, y = event.x, event.y canvas.create_oval(x-10, y-10, x+10, y+10, fill="red") def remove_point(event): x, y = event.x, event.y items = canvas.find_overlapping(x-10, y-10, x+10, y+10) for item in items: canvas.delete(item) root = tk.Tk() canvas = tk.Canvas(root, width=300, height=300) canvas.pack() canvas.bind("", add_point) canvas.bind("", remove_point) root.mainloop()
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.