[pygtk] Making a window just big enough to hold a certain image inside

Gerardo Marset gammer1994 at gmail.com
Fri Jun 10 09:58:23 WST 2011


This is part of my code:

imagesize = (128, 128)
window =gtk.Window()
window.resize(imagesize[0],imagesize[1])

scrolled =gtk.ScrolledWindow()
scrolled.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC)
scrolled.set_shadow_type(gtk.SHADOW_NONE)

area =gtk.DrawingArea()|
area.set_size_request(imagesize[0],imagesize[1])|

window.add(scrolled)
scrolled.add_with_viewport(area)
area.show()
scrolled.show()|
window.show()

|It creates a Window with a ScrolledWindow inside, with a Viewport 
inside, with a DrawingArea inside. I would expect the resulting window 
to be just big enough to hold a 128x128 image, but it isn't, and it has 
scrollbars.
It works if I write the second line like this:

window.resize(imagesize[0] + 2,image.size[1] + 2)

But it's ugly, and it doesn't always work. On Windows I had to use + 3.

Any help is greatly appreciated.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.daa.com.au/pipermail/pygtk/attachments/20110609/e3165de0/attachment.html>


More information about the pygtk mailing list