Re: How read glade file to gtk2?




On Mar 22, 2010, at 7:47 AM, Xiao Yafeng wrote:

I guess is ppm package of Gtk2, but not much sure since my script
could run on ubuntu correctly.


On Ubuntu Karmic, i needed to install libgtk2-perl (and did libgtk2-perl-doc to get the manpages).

Gtk2::Builder requires that you have a new enough gtk+ to support it.  If you can't get it to run, verify 
that you have gtk+ 2.12 or later, and  version 1.160 or newer of the Gtk2 perl module.


The script below runs just fine on Karmic.  It's just a collection of the snippets from this thread, with 
minor tweaks.


#!/usr/bin/env perl

use Gtk2 -init;

my $builder = Gtk2::Builder->new();

my $ui = '
<?xml version="1.0"?>
<interface>
 <requires lib="gtk+" version="2.16"/>
 <!-- interface-naming-policy project-wide -->
 <object class="GtkWindow" id="window">
   <child>
     <object class="GtkVPaned" id="vpaned1">
       <property name="visible">True</property>
       <property name="can_focus">True</property>
       <property name="orientation">vertical</property>
       <child>
         <object class="GtkLabel" id="label1">
           <property name="visible">True</property>
           <property name="label" translatable="yes">Hello world</property>
         </object>
         <packing>
           <property name="resize">False</property>
           <property name="shrink">True</property>
         </packing>
       </child>
       <child>
         <placeholder/>
       </child>
     </object>
   </child>
 </object>
</interface>
';
$builder->add_from_string ($ui);

my $object = $builder->get_object("window");
$object->show_all();
$object->signal_connect (destroy => sub {Gtk2->main_quit});
Gtk2->main();

__END__


--
Sallah!  I said no camels!  That's five camels!  Can't you count?
  -- Indiana Jones




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