ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> image-sig
image-sig
Re: [Image-SIG] PhotoImage Class
by Fredrik Lundh other posts by this author
Apr 6 2006 6:19AM messages near this date
[Image-SIG] PhotoImage Class | [Image-SIG] Error when saving JPEG with quality above 85 and optimize
Eric Germaneau wrote:

>  I wish to ise the photimage class and I'm wondering wether someone would
>  have an example ....

the basics are really simple:

    import ImageTk

    photo = ImageTk.PhotoImage(file="somefilename")

or

    im = ... some image operation ...

    photo = ImageTk.PhotoImage(im)

The resulting object can be used everywhere you can use a Tkinter.PhotoImage
object

    http://effbot.org/tkinterbook/photoimage.htm

e.g.

    label = Label(image=photo)

here's a complete example:

    import sys
    import Image, ImageTk, Tkinter

    root = Tkinter.Tk()

    im = Image.open(sys.argv[1])
    im.thumbnail((400, 400))

    photo = ImageTk.PhotoImage(im)

    label = Tkinter.Label(root, image=photo)
    label.pack()

    # see note on http://effbot.org/tkinterbook/photoimage.htm
    label.image = photo

    root.mainloop()

the above script loads the image given as an argument, resizes it to 400x400 (max),
and displays it in a Tkinter label widget.

hope this helps!

</F>  



_______________________________________________
Image-SIG maillist  -  Image-SIG@[...].org
http://mail.python.org/mailman/listinfo/image-sig
Thread:
Eric Germaneau
Fredrik Lundh

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved