Re: Invisible GtkImage



Hi Kip,
After setting the rescaled image, you should probably "Chain Up" to the
default size_allocate method.

I'm not a python expert, but I believe

Gtk.Image.do_size_allocate(self, allocation)

Hey Andrew. You are right. I had no idea that that had to be done, but
based on my knowledge of other windowing toolkits and the underlying
native implementation, what you suggest makes sense.

at the end of your override should work. Looking at the implementation, the
allocation needs to be stored in GtkWidget's private structure. Without
chaining up, the allocation is never stored, and thus when on_draw() is
called it is likely making a 0x0 sized Cairo context.

That makes sense, but should the allocation passed to the base class's
do_size_allocate() be the original allocation parameter that was passed
into the override, or the one that I modified to contain the new image
dimensions adjusted to maintain the aspect ratio?

If I use the allocation passed into the override, the pixels in the
image appear to rescale appropriately, but the image as a whole does
not. It grows horizontally, but the height of the widget remains fixed.

Any suggestions? The image is being added to the GtkAssistant page as
such...

        page._bannerImage = BannerImage() #Gtk.Image()
        page.pack_start(page._bannerImage, False, False, 0)
        page.reorder_child(page._bannerImage, 0)

Thanks for your help.

-- 
Kip Warner -- Software Engineer
OpenPGP encrypted/signed mail preferred
http://www.thevertigo.com


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]