-
Notifications
You must be signed in to change notification settings - Fork 1
/
paint.py
30 lines (24 loc) · 821 Bytes
/
paint.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from Tkinter import *
from Image import *
def paint(event):
black = "#000000"
x1, y1 = (event.x - 5), (event.y - 5)
x2, y2 = (event.x + 5), (event.y + 5)
w.create_oval(x1, y1, x2, y2, fill=black)
def save():
image = w.postscript(file="image.jpg",
height=100, width=100,
colormode="color")
def clear():
w.delete("all")
canvas_width = 500
canvas_height = 500
c = Tk()
message = Label(c, text = "Press & slowly drag the mouse to draw" )
message.pack(side=TOP)
w = Canvas(c, width=canvas_width, height=canvas_height,bg="white")
B = Button(c, text ="Save", command = save, anchor = N).pack(side=LEFT)
B2 = Button(c, text="Clear", command = clear, anchor = N).pack(side=LEFT)
w.pack(expand = YES, fill = BOTH)
w.bind("<B1-Motion>", paint)
mainloop()