RE: HList item values

[email protected]
Newsgroups gmane.comp.lang.perl.tk
Message-ID <[email protected]>
You could either store the name as data associated with each row in the
HList, and then use the "info" method like you were:
        $grid->add($unique_rowname, -data =>
$customers[$row_number][1]);
        ...
        print $grid->info("data",0);

Or else just look up the text of the item in column 1 with itemCget (the
complement to itemConfigure, which you're already using):
        $grid->itemCget($unique_rowname, 1, -text);

HTH,
	Dave

-----Original Message-----
From: [email protected] [mailto:[email protected]]
On Behalf Of [email protected]
Sent: Wednesday, April 27, 2005 12:47 PM
To: [email protected]
Subject: HList item values

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]

-++**==--++**==--++**==--++**==--++**==--++**==--++**==
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.