Skip to content

Instantly share code, notes, and snippets.

@almorel
Created October 28, 2011 19:37
Show Gist options
  • Save almorel/1323270 to your computer and use it in GitHub Desktop.
Save almorel/1323270 to your computer and use it in GitHub Desktop.
from Tkinter import *
import Image #PIL
import ImageTk #PIL
import sys
import getopt
try:
if len(sys.argv) == 1:
raise ValueError, "No image filename specified"
im = Image.open(sys.argv[1])
#print im.size, im.mode, im.format
root = Tk()
canvas = Canvas(root, height=im.size[1]+20, width=im.size[0]+20)
canvas.pack(side=LEFT,fill=BOTH,expand=1)
photo = ImageTk.PhotoImage(im)
item = canvas.create_image(10,10,anchor=NW, image=photo)
mainloop()
except Exception, e:
print >>sys.stderr, e
print "USAGE: HelloImage <image filename>"
sys.exit(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment