Re: Test for whether a widget has children



On Fri, Jul 23, 2010 at 04:05, Mike Martin <mike redtux org uk> 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

Do you in fact ask how to determine if an object has a method called
"get_children"?
Then the answer is "can".

if ($vbox->can('get_children') {
    for my $widget ($vbox->get_children) {
        ...
    }
}

I've googled and searched API docs but cant see anything
Not Gtk, just Perl's OOP.



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