Gossamer Forum
Home : General : Perl Programming :

How to configure a HListplus widget

Quote Reply
How to configure a HListplus widget

Hi Monk,
Suppose I have a Hlistplus widget with some data in it in some rows and under some column headers. Assume if I want to enter a new set of data in an already existing entryPaths, then how can I do that deleting the existing data in those rows.


While doing that I am getting following error :


XS_Tk__Callback_Call error:element "0" already exists at /user/perl_5.8.8/lib/Tk.pm line 250.

XS_Tk__Callback_Call: Command not found.


I am just copy/pasting a sample code here :


Code:
use Tk;
use HListplus;
my $mw = MainWindow->new();
# CREATE HEADER STYLE 1
my $headerstyle1 = $mw->ItemStyle(
'window',
-anchor => 'nw',
-pady => -10,
-padx => 10,
);
# CREATE MY HLIST
my $hlist = $mw->Scrolled(
'HListplus',
-scrollbars => 'oe',
-columns => 2,
-header => 1,
-width => 40,
-headerstyle => $headerstyle1,
)->pack( -side => 'left', -expand => 'yes', -fill => 'both' );
# CREATE HEADER STYLE 2
my $headerstyle = $hlist->ItemStyle(
'window',
-anchor => 'nw',
-pady => 0,
-padx => 10,
);
$hlist->header(
'create', 0,
-itemtype => 'resizebutton',
-style => $headerstyle,
-text => 'Test Name',
-activebackground => 'white',
);
$hlist->header(
'create', 1,
-itemtype => 'resizebutton',
-style => $headerstyle,
-text => 'Status',
-activebackground => 'white',
);
my $red = $hlist->ItemStyle( 'text', -foreground => '#800000',
-background => 'white' );
my $blue = $hlist->ItemStyle( 'text', -foreground => '#000080',
-anchor => 'e', -background => 'white' );
foreach ( [ Joe => '$10,000' ], [ Peter => '$20,000' ], [ Raj => '$90,
000 something to make it very much wider' ],
[ Zinh => '$0' ] )
{
my $e = $hlist->addchild("");
$hlist->itemCreate( $e, 0, -itemtype => 'text', -text => $_->[0], -style => $red );
$hlist->itemCreate( $e, 1, -itemtype => 'text', -text => $_->[1], -style => $blue );
$hlist->selectionClear();
}
Tk::MainLoop;



All I want to know is, if at a later point of time using this same $hlist object how can I enter a new set of data in the 0th and 1st entrypath instead of the existing Joe->$10,000 and Peter->$20,000
Thanks