Re: help needed with viewports and scrolledwindows




On Nov 12, 2005, at 9:21 PM, Mr Brian Kiefel wrote:

When I do a set_value to a scrolledwindow nothing happens.

Are you doing this while the main loop is running? Are the adjustment bounds set up correctly?

This adjustment of your code works for me:


use Gtk2 -init;

$window = Gtk2::Window->new;
$window->set_default_size(100,50);
$vbox = Gtk2::VBox->new(0,0);

my $scwin = Gtk2::ScrolledWindow->new();
$ha1 = $scwin->get_hadjustment;
my $label = Gtk2::Label->new("hello there this line should not fit");
$scwin->add_with_viewport($label);
$vbox->pack_start($scwin, 0, 0,0);
$window->add($vbox);

$ha1->{dir} = +1;
Glib::Timeout->add (50, sub {
        my $current = $ha1->get_value;
        my $increment = $ha1->step_increment;
        my $new = $current + $increment * $ha1->{dir};
        if ($new >= $ha1->upper - $ha1->page_size) {
                $new = $ha1->upper - $ha1->page_size;
                $ha1->{dir} = -1;
        } elsif ($new <= $ha1->lower) {
                $new = $ha1->lower;
                $ha1->{dir} = +1;
        }
        $ha1->set_value ($new);
        return 1;
});

$window->signal_connect (destroy => sub {Gtk2->main_quit});
$window->show_all;
Gtk2->main;



--
"that's it! you're a genius!" "yes. that's what i think. do you think i deserve a raise?"
    - dialogue from 'Godzilla versus Mothra', 1964




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