sandeep.ses has asked for the wisdom of the Perl Monks concerning the following question:

i have a hlist with multiple colums in it. i am able to select all the rows in it expect for the 1st row . i tried selecting the second row and then tried to select the first row with keyboard then i was able to select it but when i click it with the mouse it doesnt allow me to do it . i tried a sample hlist program from perltk.org it worked fine but when i use it in my program it doesnt work . can anyone help me with this here is my code
my $helix_result_list=$helix_lf->Scrolled('HList', -scrollbars => 'oe', -width => 50, -height => 20, -header => 1, -columns => 5, -selectbackground=>'green', -command =>\&change_hlist_bg )->pack(-expand=>1, -fill=>'both', -padx=>2, -pady=>2); $helix_result_list->headerCreate( 0, -text => 'Chain'); $helix_result_list->headerCreate( 1, -text => 'Ssqno'); $helix_result_list->headerCreate( 2, -text => 'Esqno'); $helix_result_list->headerCreate( 3, -text => 'Class'); $helix_result_list->headerCreate( 4, -text => 'Sequence'); $helix_result_list->add($main::helix_result_count); printf "$main::helix_result_count\n"; $helix_result_list->itemCreate($main::helix_result_count,0,-text=> +$chainid); $helix_result_list->itemCreate($main::helix_result_count,1,-text=> +$value1); $helix_result_list->itemCreate($main::helix_result_count,2,-text=> +$value2); $helix_result_list->itemCreate($main::helix_result_count,3,-text=> +$class); $helix_result_list->itemCreate($main::helix_result_count,4,-text=> +sprintf("%s",substr($main::seqres{$chainid},$value1,$value2-$value1+1 +)));

Replies are listed 'Best First'.
Re: Problem with Hlist in Perl/TK
by davidj (Priest) on Jul 08, 2004 at 01:19 UTC
    First of all, it is difficult to debug what you posted since the code you posted has only 1 row in the HList widget.
    Second, I modified it a bit to add a second duplicate row, removed the $main references and it works fine for me.

    #!/usr/bin/perl -w use strict vars; use Tk; require Tk::HList; my $helix_lf = MainWindow->new(); my $helix_result_list=$helix_lf->Scrolled('HList', -scrollbars => 'oe', -width => 50, -height => 20, -header => 1, -columns => 5, -selectbackground=>'green', -command =>\&change_hlist_bg )->pack(-expand=>1, -fill=>'both', -padx=>2, -pady=>2); $helix_result_list->headerCreate( 0, -text => 'Chain'); $helix_result_list->headerCreate( 1, -text => 'Ssqno'); $helix_result_list->headerCreate( 2, -text => 'Esqno'); $helix_result_list->headerCreate( 3, -text => 'Class'); $helix_result_list->headerCreate( 4, -text => 'Sequence'); $helix_result_list->add(helix_result_count); $helix_result_list->add(helix_result_count1); $helix_result_list->itemCreate(helix_result_count,0,-text=> "one"); $helix_result_list->itemCreate(helix_result_count,1,-text=> "two"); $helix_result_list->itemCreate(helix_result_count,2,-text=> "three"); $helix_result_list->itemCreate(helix_result_count,3,-text=> "four"); $helix_result_list->itemCreate(helix_result_count,4,-text=>"five"); $helix_result_list->itemCreate(helix_result_count1,0,-text=> "one"); $helix_result_list->itemCreate(helix_result_count1,1,-text=> "two"); $helix_result_list->itemCreate(helix_result_count1,2,-text=> "three"); $helix_result_list->itemCreate(helix_result_count1,3,-text=> "four"); $helix_result_list->itemCreate(helix_result_count1,4,-text=>"five"); MainLoop;

    Hope this helps,
    davidj

    update:The reason I removed the references to "main" package is because I was getting the following error:
    D:\PerlProjects\tests\HList.pl Entry "" not found at C:/Perl/site/lib/Tk.pm line 228.
    Now, you may need the $main references. I couldn't tell by the code you posted. However, try taking them out and see if it works for you.
      the reason i had one row was because i have it called in a subroutine . and the subroutine gets called whenever i need to add a row . so removing main:: will not help me . it would give me variable not found error.
        With what you have posted, it is impossible to say why your code is not working. Post more of it, all if possible. It will be easier to check.

        davidj
Re: Problem with Hlist in Perl/TK
by eserte (Deacon) on Jul 08, 2004 at 09:15 UTC
    I can reproduce the problem if the entry path is undefined. So make sure that $helix_result_count is initially zero, not undef.