Re: Layout problems when getting widgets from glade file



What I'm trying to do is to get the program using the glade file to
look like the one that isn't.

I got your manual gui script to give a similar result as your glade
generated version
by including the line.
$window->set_default_size(300,60);

Sorry I think I was unclear on this point and I appreciate this
suggestion but the problem is I need to get the glade file one to
shrink so that when I add more widgets to the Gtk2::Table in my
&ret_table() function, the window isn't too large for the screen upon
executing the *.pl file that loads the gui.

Upon further testing this actually works if the labels are all the
same size - see (same_len_labels.png)
In with_glade.pl change ret_table to:

sub ret_table
{
        my $table = Gtk2::Table->new(2,9,FALSE);

        # Title Row
        my $lbl_num = Gtk2::Label->new("label 1");
        my $lbl_time = Gtk2::Label->new("label 2");
        my $lbl_objectives = Gtk2::Label->new("label 3");
        my $lbl_tasks = Gtk2::Label->new("label 4");
        my $lbl_resources = Gtk2::Label->new("label 5");

        my $tcol_sep1 = Gtk2::VSeparator->new;
        my $tcol_sep2 = Gtk2::VSeparator->new;
        my $tcol_sep3 = Gtk2::VSeparator->new;
        my $tcol_sep4 = Gtk2::VSeparator->new;

        # Layout title row
        $table->attach_defaults($lbl_num, 0,1,0,1);
        $table->attach_defaults($tcol_sep1, 1,2,0,1);
        $table->attach_defaults($lbl_time, 2,3,0,1);
        $table->attach_defaults($tcol_sep2, 3,4,0,1);
        $table->attach_defaults($lbl_objectives, 4,5,0,1);
        $table->attach_defaults($tcol_sep3, 5,6,0,1);
        $table->attach_defaults($lbl_tasks, 6,7,0,1);
        $table->attach_defaults($tcol_sep4, 7,8,0,1);
        $table->attach_defaults($lbl_resources, 8,9,0,1);

        return $table;

}

However, if the labels are different lengths the window becomes too
large for the screen (diff_len_labels.png).  The rest of the last two
labels are off the right hand side of my screen.

Change with_glade.pl &ret_table to:

sub ret_table
{
        my $table = Gtk2::Table->new(2,9,FALSE);

        # Title Row
        my $lbl_num = Gtk2::Label->new("Num");
        my $lbl_time = Gtk2::Label->new("Time/Session");
        my $lbl_objectives = Gtk2::Label->new("Objectives/Learning Outcomes");
        my $lbl_tasks = Gtk2::Label->new("Activities/Tasks/Content");
        my $lbl_resources = Gtk2::Label->new("Resources");

        my $tcol_sep1 = Gtk2::VSeparator->new;
        my $tcol_sep2 = Gtk2::VSeparator->new;
        my $tcol_sep3 = Gtk2::VSeparator->new;
        my $tcol_sep4 = Gtk2::VSeparator->new;

        # Layout title row
        $table->attach_defaults($lbl_num, 0,1,0,1);
        $table->attach_defaults($tcol_sep1, 1,2,0,1);
        $table->attach_defaults($lbl_time, 2,3,0,1);
        $table->attach_defaults($tcol_sep2, 3,4,0,1);
        $table->attach_defaults($lbl_objectives, 4,5,0,1);
        $table->attach_defaults($tcol_sep3, 5,6,0,1);
        $table->attach_defaults($lbl_tasks, 6,7,0,1);
        $table->attach_defaults($tcol_sep4, 7,8,0,1);
        $table->attach_defaults($lbl_resources, 8,9,0,1);

        return $table;

}

How do I get my program to cope with different length labels so the
window fits on the screen?

Attachment: same_len_labels.png
Description: PNG image

Attachment: diff_len_labels.png
Description: PNG image



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