O'Reilly logo

Python 2.6 Graphics Cookbook by Mike Ohlson de Fine

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 mouse-line editor

We edit (change) a shape drawn using the mouse after the drawing is finished.

Getting ready

To limit the complexity and length of the code, we have excluded the facilities provided in the previous recipe for storing and recalling the drawn shape. So for this recipe no storage folders will be used.

# mouse_shape_editor_1.py #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> from Tkinter import * import math root = Tk() root.title("Left drag to draw, right to re-position.") cw = 600 # canvas width ch = 650 # canvas height chart_1 = Canvas(root, width=cw, height=ch, background="#ffffff") chart_1.grid(row=1, column=1) linedrag = {'x_start':0, 'y_start':0, 'x_end':0, 'y_end':0} map_distance = 0 dist_meter = 0 x_initial = 0 y_initial = 0 ...

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