HList item values

[email protected]
Newsgroups gmane.comp.lang.perl.tk
Message-ID <[email protected]>
I need to be able to return the item text but haven't been able to 
figure it out.


#!/usr/bin/perl
use strict;
use Tk;
use Tk::HList;
use Tk::BrowseEntry;

my $mw = MainWindow->new;

# Mainwindow: sizex/y, positionx/y
$mw->geometry("500x200+100+120");

# Default value
&create_datagrid($mw);

MainLoop;

sub create_datagrid {
    my $mother = shift;

    my @headers = ( "Financial status", "Name", "City", "Phone" );
    my @customers = (
        [ 'bad',  'Richard', 'Nuernberg', '123' ],
        [ 'good', 'Roland',  'Fuerth',    '586' ],
        [ 'fair', 'Peter',   'Zirndorf',  '933' ],
    );

    my $grid = $mother->Scrolled(
        'HList',
        -head       => 1,
        -columns    => scalar @headers,
        -scrollbars => 'e',
        -width      => 40,
        -height     => 10,
        -background => 'white',
    )->pack();

    foreach my $x ( 0 .. $#headers ) {
        $grid->header(
            'create',
            $x,
            -text             => $headers[$x],
            -headerbackground => 'gray',
        );
    }

    foreach my $row_number ( 0 .. $#customers ) {
	my $unique_rowname = $row_number;

        $grid->add($unique_rowname);
        foreach my $x ( 0 .. 3 ) {
            $grid->itemCreate( $unique_rowname, $x,
                -text => $customers[$row_number]->[$x] );

            # You can change gridcontent later
            $grid->itemConfigure( $unique_rowname, $x, -text => "don't 
care" )
              if rand > 0.5 and $x == 0;
        }
    }

    $grid->selectionSet(0);
    
    #idealy i want to store the name at row 0 column 1 in a variable
    # i used numbers for the identifiers
    print $grid->info("data",0);
    
}

-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.