PageRenderTime 19ms CodeModel.GetById 14ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/Demo/tkinter/guido/imagedraw.py

http://unladen-swallow.googlecode.com/
Python | 23 lines | 19 code | 3 blank | 1 comment | 0 complexity | da4fb193d7f7d66de4931af0e53e382d MD5 | raw file
 1"""Draw on top of an image"""
 2
 3from Tkinter import *
 4import sys
 5
 6def main():
 7    filename = sys.argv[1]
 8    root = Tk()
 9    img = PhotoImage(file=filename)
10    w, h = img.width(), img.height()
11    canv = Canvas(root, width=w, height=h)
12    canv.create_image(0, 0, anchor=NW, image=img)
13    canv.pack()
14    canv.bind('<Button-1>', blob)
15    root.mainloop()
16
17def blob(event):
18    x, y = event.x, event.y
19    canv = event.widget
20    r = 5
21    canv.create_oval(x-r, y-r, x+r, y+r, fill='red', outline="")
22
23main()