Re: Test for whether a widget has children

On 07/22/2010 08:05 PM, Mike Martin wrote:
Does such a thing exist in Gtk? eg: if I do something like

foreach my $widget ($vbox->get_children){
print $widget
It will fail if there are any widgets that dont have children such as
a label or a GTkEntry

So you just want to know, in the above code, whether $vbox is something with children?

I don't know of anything offhand, although there are methods in Gtk::Widget that makes it look like there 
must be some way to figure it out.

However, why not do an isa check to see if it derives from Gtk2::Container?

if($vbox->isa('Gtk2::Container')) {
    foreach my $widget ($vbox->get_children){
        print $widget;


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