Re: Repacking a table

Johan Aberg wrote:
I'm trying to update the items packed in the table but I'm not sure I
understand how to do it. I was trying to destroy everything in the
table and then loop over my new images and then call attach to rebuild
the table with new the images. For various reasons in my design,  I
can not just simply keep the images and just replace their pixbuffers
to update the content of the table.

That seems like an odd limitation.  The Gtk2::Image widgets are just views for
your images and should be interchangeable.  Can't you fix your design?  After
all, if you wind up having to manipulate a table as you propose below, you're
doing something that is not very idiomatic for the toolkit and there's likely
to be an easier way.

For example, can you use a Gtk2::IconView instead of this manual table thing?

My question is, is it possible to repack after the main event loop has
been started? I seems to be able to destroy items, but not add table
items once the program is running?

Yes.  Your solution will involve Gtk2::Container::remove() and

Note that Gtk2::Table does not appear to have a way to get the widget at some
location, so you need to know which child is which when you iterate over the
list of children.

When I destroy an item with children, does GTK2 remove the children
and free up the memory they allocated?

For the most part, yes.  Watch for reference cycles.  This is yet another
reason you'd likely be better off keeping only the pixbufs...

muppet <scott at asofyet dot org>

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