use Glib qw/TRUE FALSE/; use Gtk2 -init; use Gtk2::Ex::Simple::List; # Create the menu window my $window = Gtk2::Window->new; $window->signal_connect('delete_event' => sub {exit;}); $window->set_border_width(0); $window->set_position('center_always'); $window->set_title('Test simple list'); # Create a vertical packing box my $vbox = Gtk2::VBox->new(FALSE, 0); $window->add($vbox); # Create a horizontal pane my $hpaned = Gtk2::HPaned->new; $vbox->pack_end($hpaned, TRUE, TRUE, 0); # Add a notebook on the right side of the pane my $notebook = Gtk2::Notebook->new; $hpaned->add2($notebook); # Add a simple list $list = Gtk2::Ex::Simple::List->new( 'Key' => 'text', 'Value' => 'text', ); # Make each column selectable $list->signal_connect (row_activated => sub { my ($sl, $path, $column) = @_; my $rowRef = $sl->get_row_data_from_path($path); print ('Data: ' . join(' ' , @$rowRef)); }); @{$list->{data}} = ( [ 'Red', 'colour'], ['Yellow', 'colour'], ['Orange', 'fruit'], ); # Make the simple list scrollable $scroller = Gtk2::ScrolledWindow->new; $scroller->set_policy('automatic', 'automatic'); $scroller->add_with_viewport($list); $vbox->pack_start($scroller, 1, 1, 0); # Open the window $window->set_default_size(700, 450); $window->show_all; # Start the Gtk main loop Gtk2->main;