#!/usr/bin/perl use warnings; use strict; use Gtk2 qw/-init/; use Gtk2::SimpleList; my $count = 0; my $win = Gtk2::Window->new; $win->signal_connect( 'destroy' => sub{exit} ); $win->set_default_size(300,200); $win->set_position('center'); my $sw = Gtk2::ScrolledWindow->new (undef, undef); $sw->set_policy ('automatic', 'automatic'); my $ha1 = $sw->get_vadjustment; my $list = Gtk2::SimpleList->new('test' => 'int',); $sw->add($list); $win->add($sw); $win->show_all; Glib::Timeout->add(500, \&update, $list); Gtk2->main; sub update{ my $list = shift; push @{$list->{data}},rand $count++; # bad hack method # $list->scroll_to_point(0,1000); # muppet's suggestion for better scrolling # find the path of the last row in the model. my $path = Gtk2::TreePath->new_from_indices (scalar (@{ $list->{data} }) - 1); # the scalar-of-array is actually just a tie() wrapper for # n_rows = $list->get_model->iter_n_children (undef); # now scroll to that row. let all of the other parameters # default, because we don't need them. $list->scroll_to_cell ($path); return 1; }