Hi All, I am trying to learn how to use VBox and Table layouts. At the moment I am getting different results when either coding the gui by hand or creating it in glade (with what I thought were similar options). Without glade: #!/usr/bin/perl use Gtk2 -init; use Gtk2::GladeXML; use Glib qw/TRUE FALSE/; # Create a new window $window = Gtk2::Window->new('toplevel'); # Main window vbox contains button and vbox2 # ($homogenous, $spacing) $vbox1 = Gtk2::VBox->new(FALSE, 5); # Button to add tables to vbox2 $btn_add = Gtk2::Button->new("Add"); # Add button to main vbox # ($child, $expand, $fill, $padding) $vbox1->pack_start($btn_add, FALSE, TRUE, 0); # Create vbox where want to add table of widgets # ($homogenous, $spacing) $vbox2 = Gtk2::VBox->new(FALSE, 5); # Create a table of widgets # ($rows, $columns, $homogenous) $table = &ret_table(); # Show the widgets # ($child, $expand, $fill, $padding) $vbox2->pack_start($table, TRUE, TRUE, 0); $vbox2->show_all; $vbox1->pack_start($vbox2, TRUE, TRUE, 0); $vbox1->show_all; # Add main vbox to window $window->add($vbox1); # Quit when user clicks on the close button/alt-f4 etc. $window->signal_connect (destroy => sub { Gtk2->main_quit; }); # Maximise the window #$window->maximize; # Show main window $window->show; # Run main loop. Gtk2->main; sub ret_table { my $table = Gtk2::Table->new(2,9,FALSE); my $label = Gtk2::Label->new("Blah"); $label->set_alignment(0,0); $table->attach_defaults($label,0,1,0,1); return $table; } When I run it i get a window that looks like 'no_glade.png' However if I use glade for the vboxes and create the table in my code i get a picture similar to 'with_glade.png' With glade: #!/usr/bin/perl use Gtk2 -init; use Gtk2::GladeXML; # Read in glade file with gui $gladexml = Gtk2::GladeXML->new('with_glade.glade'); # Get main window vbox $vbox1 = $gladexml->get_widget('vbox1'); # Get vbox where want to add table of widgets $vbox2 = $gladexml->get_widget('vbox2'); # Create a table of widgets $table = &ret_table(); # Show the widgets # $child, $expand, $fill, $padding $vbox2->pack_start($table, TRUE, TRUE, 0); $vbox2->show_all; # Get main window from widget tree. $main_window = $gladexml->get_widget('window1'); # Quit when user clicks on the close button/alt-f4 etc. $main_window->signal_connect (destroy => sub { Gtk2->main_quit; }); # Maximise window #$main_window->maximize; # Run main loop. Gtk2->main; sub ret_table { my $table = Gtk2::Table->new(2,9,FALSE); my $lbl_num = Gtk2::Label->new("Blah"); $label->set_alignment(0,0); $table->attach_defaults($lbl_num, 0,1,0,1); return $table; } What I'm trying to do is to get the program using the glade file to look like the one that isn't. I would ideally like to be able to use glade than hand code the entire gui. Is anyone able to help me work out what I'm doing wrong? Peter.
Attachment:
with_glade.glade
Description: application/glade
Attachment:
no_glade.png
Description: PNG image
Attachment:
with_glade.png
Description: PNG image