~ubuntu-branches/ubuntu/maverick/python3.1/maverick

« back to all changes in this revision

Viewing changes to Demo/tkinter/guido/imagedraw.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2009-03-23 00:01:27 UTC
  • Revision ID: james.westby@ubuntu.com-20090323000127-5fstfxju4ufrhthq
Tags: upstream-3.1~a1+20090322
ImportĀ upstreamĀ versionĀ 3.1~a1+20090322

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"""Draw on top of an image"""
 
2
 
 
3
from tkinter import *
 
4
import sys
 
5
 
 
6
def 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
 
 
17
def 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
 
 
23
main()