How to resize tkinter label widget
Fredrik Lundh
fredrik at pythonware.com
Sat Sep 8 08:36:14 EDT 2001
Eric Frey wrote:
> I am trying to let users resize an image created with PIL and expand the
> label widget (and the window) that I am using to display the image. I
> am using the PIL ImageTk module to create PhotoImages and displaying it
> using a label. I can successfully resize the image using PIL and paste
> it back into the photoimage.
footnote: Pasting into a visible ImageTk.PhotoImage can
be very slow. It's usually more efficient to create a new
PhotoImage object.
> When I do this, the label widget stays the same size. I
> would like to expand it so it contains the new image.
given a label widget "w" and a PIL image "im",
w.config(width=im.size[0], height=im.size[1])
should do the trick.
hope this helps!
</F>
<!-- (the eff-bot guide to) the python standard library:
http://www.pythonware.com/people/fredrik/librarybook.htm
-->
More information about the Python-list
mailing list