Help with TixGrid, segfault in Tix_LinkListNext
Norbert Preining <[email protected]> Sun, 6 Dec 2009 07:38:24 +0100
| Newsgroups | gmane.comp.lang.perl.tk |
|---|---|
| Message-ID | <[email protected]> |
Hi everyone,
I am having a problem with TixGrid. I want to embedd a check button
in the first column and at certain points update the grid (the list
of items to be shown).
I have code that actually works, but there is a problem with the selection.
As soon as I update the grid and scroll down the checkbuttons are
drawn incorrectly, namely some are selected that should not be.
Ok, that sounds rather complicted, I agree, so I tried to create a
minimal example, but that, even worse, made Tk segfault in
Tix_LinkListNext.
Here the code:
$^W = 1;
use strict;
use Tk;
use Tk::TixGrid;
my $mw = MainWindow->new();
my $g = $mw->TixGrid(-topmargin => 1);
my @packs = qw/a b c d e f g h i j k l m n o p q r s t u v w x y z/;
my %Packages;
$g->set(0,0, -itemtype => 'text', -text => "CB");
$g->set(1,0, -itemtype => 'text', -text => "Name");
my $i = 1;
for my $p (@packs) {
$Packages{$p}{'selected'} = $i%2;
$Packages{$p}{'cb'} = $g->Checkbutton(-variable => \$Packages{$p}{'selected'});
$g->set(0,$i, -itemtype => 'window', -widget => $Packages{$p}{'cb'});
$g->set(1,$i, -itemtype => 'text', -text => $p);
$i++;
}
$g->pack;
$mw->Button(-text => "Update Grid", -command => \&update_grid)->pack;
MainLoop;
sub update_grid {
my (undef, $curlines) = $g->index(0, 'max');
$g->deleteRow(1, $curlines+1);
pop @packs;
my $i = 1;
for my $p (@packs) {
$g->set(0,$i, -itemtype => 'window', -widget => $Packages{$p}{'cb'});
$g->set(1,$i, -itemtype => 'text', -text => $p);
$i++;
}
print "Foo\n";
}
Interestingly it crashes not always at the first time, but sometimes
at the n-th time I press the update grid button.
It is not the $g->set in the update_grid, because I always come around
the print "Foo\n"; but after that segfaults occur.
So I wonder if something is wrong with the above code, or some bug in
TixGrid I am hitting?
Thanks a lot for any suggestion
Norbert
------------------------------------------------------------------------
Norbert Preining preining@{jaist.ac.jp, logic.at, debian.org}
JAIST, Japan TU Wien, Austria Debian TeX Task Force
DSA: 0x09C5B094 fp: 14DF 2E6C 0307 BE6D AD76 A9C0 D2BF 4AA3 09C5 B094
------------------------------------------------------------------------
CLACKAVOID (n.)
Technical BBC term for a page of dialogue from Blake's Seven.
--- Douglas Adams, The Meaning of Liff
--++**==--++**==--++**==--++**==--++**==--++**==--++**==
ptk mailing list
[email protected]
https://mailman.stanford.edu/mailman/listinfo/ptk