in reply to Have there been sightings of TK::TixGrid in the wild?
Take a look at Tk::TableMatrix. It's included in the Activestate distribution, and has more documentation than Tk::TixGrid. Here's some example code with notes, extracted from one of my projects. This should give you a good start with the widget, but be sure to read the docs, there's a lot more to it.
# set up the Tk::TableMatrix grid my $grid = $mw->Scrolled('TableMatrix', -scrollbars => 'osoe', -sparsearray => 0, -titlecols => 1, # first col does not scroll -titlerows => 1, # top row does not scroll -roworigin => -1, # first scrolling (data) row is 0 -colorigin => -1, # first scrolling (data) col is 0 -padx => 2, -colwidth => 20, -anchor => 'w', -background => 'white', -resizeborders => 'none', -justify => 'left', -browsecommand => \&clickLeft, )->pack( -side =>'right', -expand => 1, -fill => 'both', ); # collect the data # column labels my @colLabels = qw( column labels here ... etc ); # from database my $data = $dbh->selectall_arrayref($sql); # number of columns my $cols = scalar @{$data->[0]}; # number of rows my $rows = 20; # populate the grid with data # hashref to hold Tk type list for grid values my $vals = {}; # add column labels to first row for (0..$cols -1){ $vals->{"-1,$_"} = $colLabels[$_]; } # add data to subsequent rows for my $ro (0..$rows -1){ # put row numbering into first column $vals->{"$ro,-1"} = $ro +1; # put data from Perl array ref into Tk list for my $co (0..$cols -1){ $vals->{"$ro,$co"} = $data->[$ro][$co]; } } # configure binds Tk list to the grid $grid->configure( -rows => $rows +1, -cols => $cols +1, -variable => $vals, );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Have there been sightings of TK::TixGrid in the wild?
by generator (Pilgrim) on Apr 10, 2009 at 21:31 UTC |