Re: Inspecting a Gtk2::GladeXML object
- From: Grant McLean <grant mclean net nz>
- To: gtk-perl-list gnome org
- Subject: Re: Inspecting a Gtk2::GladeXML object
- Date: Fri, 23 Jun 2006 20:04:50 +1200
On Fri, 2006-06-23 at 15:09 +1000, Daniel Kasak wrote:
Hi all.
Is there a way to list all widgets in a Glade XML file?
It would be nice if I could iterate over them without knowing what they
are in advance ...
I can't see anything in the Gtk2::GladeXML API, but it is XML, so you
can parse the file using your favourite XML module; e.g.:
use XML::LibXML;
my $parser = XML::LibXML->new();
my $doc = $parser->parse_file($file);
foreach my $widget ($doc->findnodes('//*[name() = "widget"]')) {
my $class = $widget->findvalue('./@class');
my $id = $widget->findvalue('./@id');
print "$class: $id\n";
}
The widget class names are the C names rather than the Perl names, but
that shouldn't be too much of a barrier.
Cheers
Grant
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]