summaryrefslogtreecommitdiffstats
path: root/Demo
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1995-10-11 18:27:23 (GMT)
committerGuido van Rossum <guido@python.org>1995-10-11 18:27:23 (GMT)
commit81a07ceddc86d75e48242f0b94e9e3f5bab72e5b (patch)
treec73b9e83057880eb11b5b0cf23f3965faa8208aa /Demo
parente7d92d5f411df499593784c184770469a192d7de (diff)
downloadcpython-81a07ceddc86d75e48242f0b94e9e3f5bab72e5b.zip
cpython-81a07ceddc86d75e48242f0b94e9e3f5bab72e5b.tar.gz
cpython-81a07ceddc86d75e48242f0b94e9e3f5bab72e5b.tar.bz2
idraw on top of an image
Diffstat (limited to 'Demo')
-rwxr-xr-xDemo/tkinter/guido/imagedraw.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/Demo/tkinter/guido/imagedraw.py b/Demo/tkinter/guido/imagedraw.py
new file mode 100755
index 0000000..d3dba45
--- /dev/null
+++ b/Demo/tkinter/guido/imagedraw.py
@@ -0,0 +1,23 @@
+"""Draw on top of an image"""
+
+from Tkinter import *
+import sys
+
+def main():
+ filename = sys.argv[1]
+ root = Tk()
+ img = PhotoImage(file=filename)
+ w, h = img.width(), img.height()
+ canv = Canvas(root, width=w, height=h)
+ canv.create_image(0, 0, anchor=NW, image=img)
+ canv.pack()
+ canv.bind('<Button-1>', blob)
+ root.mainloop()
+
+def blob(event):
+ x, y = event.x, event.y
+ canv = event.widget
+ r = 5
+ canv.create_oval(x-r, y-r, x+r, y+r, fill='red', outline="")
+
+main()