1 """"Paint program by Dave Michell.
3 Subject: tkinter "paint" example
4 From: Dave Mitchell <davem@magnet.com>
6 Date: Fri, 23 Jan 1998 12:18:05 -0500 (EST)
8 Not too long ago (last week maybe?) someone posted a request
9 for an example of a paint program using Tkinter. Try as I might
10 I can't seem to find it in the archive, so i'll just post mine
11 here and hope that the person who requested it sees this!
13 All this does is put up a canvas and draw a smooth black line
14 whenever you have the mouse button down, but hopefully it will
15 be enough to start with.. It would be easy enough to add some
16 options like other shapes or colors...
25 """paint.py: not exactly a paint program.. just a smooth line drawing demo."""
28 xold
, yold
= None, None
32 drawing_area
= Canvas(root
)
34 drawing_area
.bind("<Motion>", motion
)
35 drawing_area
.bind("<ButtonPress-1>", b1down
)
36 drawing_area
.bind("<ButtonRelease-1>", b1up
)
41 b1
= "down" # you only want to draw when the button is down
42 # because "Motion" events happen -all the time-
47 xold
= None # reset the line when you let go of the button
53 if xold
!= None and yold
!= None:
54 event
.widget
.create_line(xold
,yold
,event
.x
,event
.y
,smooth
=TRUE
)
55 # here's where you draw it. smooth. neat.
59 if __name__
== "__main__":