Re: Tk::Hlist questions

[email protected]
Newsgroups gmane.comp.lang.perl.tk
Message-ID <092120051839.15085.4331A8F80007817800003AED22007623020B040A07000A049B9B0704D29B@comcast.net>
Hmmm... interesting question.  There is of course, more than one way to do it.
You could use recursion to get the total number of entries in the list.  i.e. get
the children of the top level and recurse through each one, returning a count
of all the children...  I can't be positive, without looking at the source, but the
HList doesn't seem to have a method for this, so you need to roll your own.

One way to get either column 0 or all columns would be to use a hash of
anonymous arrays.  The key to the hash being the HList entryPath they
are stored under...

$col0 = ${$hash{$entryPath}}[0];

@cols = @{$hash{$entryPath}};

or somesuch...  You of course have to build the hash as you add elements to
the HList.

To answer your last question, I believe you need to create an ItemStyle
for each group of settings.  (i.e. black text on yellow bg is one style, green
text on black bg is another...)  This example uses the hex representation
for the color (since there wasn't a close enough match):

    $idleBG = $hList->ItemStyle( 'text', -background => '#8f6f8f' );

Then you use it like

    $hList->itemCreate(
                    $entry,
                    $col,
                    -itemtype => 'text',
                    -text     => 'foo',
                    -style    => $idleBG,
                    );


Hope this helps.


> How can I get the total number of list entries in an Hlist?
> 
> Lets say I have 5 list entries each having 3 columns and I've used the -
> text option ($hlist->itemCreate( XX, XX, -text => "whatever");) for 
> each of the columns and then I call $hlist->info('selection'); to get 
> the list of selected entries.  How can I get the -text value for either 
> column 0 or all columns for each selected entry that was returned?
> 
> Right now I'm using seperate data arrays to achieve the above two tasks.
> 
> Finally my least important question, is it possible to use another 
> foreground color for the -text in the columns one of the list entries 
> making it different from the rest?  This is basically to make it stick 
> out more, a way of showing priority, if you will.  I'm wondering if at 
> this point I should have used listbox -tabs
> 
> Thanks.
> -++**==--++**==--++**==--++**==--++**==--++**==--++**==
> 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.