Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Insert checkbutton into MListbox

by zentara (Archbishop)
on Feb 02, 2012 at 17:01 UTC ( #951489=note: print w/replies, xml ) Need Help??

in reply to Insert checkbutton into MListbox

Just to broaden your toolkit horizons, Gtk2 will do it.
#!/usr/bin/perl use warnings; use strict; use Glib qw/TRUE FALSE/; use Gtk2 -init; use Gtk2::Ex::Simple::List; my $win = Gtk2::Window->new; $win->set_title ('Gtk2::Ex::Simple::List exapmle'); $win->set_border_width (6); $win->set_default_size (500, 300); $win->signal_connect (delete_event => sub { Gtk2->main_quit; }); my $hbox = Gtk2::HBox->new (0, 6); $win->add ($hbox); my $scwin = Gtk2::ScrolledWindow->new; $hbox->pack_start ($scwin, 1, 1, 0); $scwin->set_policy (qw/automatic automatic/); my $slist = Gtk2::Ex::Simple::List->new ( 'Text Field' => 'text', 'Bool Field1' => 'bool', 'Bool Field2' => 'bool', 'Bool Field3' => 'bool', ); @{$slist->{data}} = ( [ '1text', TRUE, TRUE, TRUE ], [ '2text', TRUE, FALSE, TRUE ], ); # (almost) anything you can do to an array you can do to # $slist->{data} which is an array reference tied to the list model push @{$slist->{data}}, [ '9text', FALSE, FALSE, TRUE ]; # mess with selections $slist->get_selection->set_mode ('multiple'); $slist->get_selection->unselect_all; $slist->select (1, 3, 5..9); # select rows by index $slist->unselect (3, 8); # unselect rows by index my @sel = $slist->get_selected_indices; # simple way to make text columns editable my $col_num = 0; $slist->set_column_editable ($col_num, TRUE); # Allow sorting on the column #$slist->get_model->set_sort_column_id(0); #Gtk2::TreeSortable::set_sort_column_id($slist, 0, undef); $scwin->add ($slist); my $vbox = Gtk2::VBox->new (0, 6); $hbox->pack_start($vbox, 0, 1, 0); # finally, a button to end it all my $btn = Gtk2::Button->new_from_stock ('gtk-quit'); $btn->signal_connect (clicked => sub { Gtk2->main_quit; }); $vbox->pack_end($btn, 0, 1, 0); $win->show_all; Gtk2->main;

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://951489]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2018-03-20 05:14 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (247 votes). Check out past polls.