CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Tk and Tk::MListbox

 



lightspd
Novice

Feb 12, 2013, 12:59 PM

Post #1 of 3 (677 views)
Tk and Tk::MListbox Can't Post

I'm having an issue with MListbox. Randomly it will throw the following error. "Can't use string ("") as a subroutine ref while "strict refs" in use at MListbox.pm line 700"

Everything works fine, till unknown happens and then constant errors till the program is restarted. The rest of the program works fine and continues to work fine. There is no change in the data being placed in the rows or columns. First code section is mine, second is from MListbox.pm. As suggested in a post on another site, I tried changing the SUPER's to Tk::Listbox, but that didn't help.


Code
 
my $searchRes = $top->DialogBox(-title => 'Search Results',
-buttons => ['OK', 'Cancel'],);
my @dispRes = qw(ID FirstName LastName);

my $ml = $searchRes->Scrolled(
qw/MListbox -selectmode single -scrollbars oe -font small /
)->pack(-expand => 1, -fill => 'both');

foreach my $colHdrs (@dispRes){
$ml->columnInsert('end',-text=>$colHdrs);
}

foreach (@dispRes){
push @row, $hash{$_}; <-- this is returned by another function, data dump shows no change.
}

$ml->insert('end', \@row);


$ml->see('end'); <-- Error get's thrown here
$ml->update;
my $answer = $searchRes->Show();


MListbox.pm around line 700. $code becomes undef and possibly other values, but that's the one that's throwing the error above and being undef.


Code
 
sub _selectionUpdate {
my ($w, $code, $l, @args) = @_;
;
if (@args) {
foreach (@{$w->{'_columns'}}) {
&$code($_->Subwidget("listbox"), @args);
}
} else {
&$code($w->{'_columns'}->[0]->Subwidget("listbox"));
}
}



wickedxter
User

Feb 12, 2013, 6:37 PM

Post #2 of 3 (674 views)
Re: [lightspd] Tk and Tk::MListbox [In reply to] Can't Post

from the module POD http://cpansearch.perl.org/src/RCS/Tk-MListbox-1.11/docs/MListbox.html


Quote
see( index )

Adjusts the view in the MListbox so that the row specified by index is visible. If the element is already visible then the command has no effect.



Quote
insert( index, @rows )

Inserts one or more rows into the MListbox before the element at index. A single row element is an array reference to the column values for that row. If an inserted row doesn't contain sufficient values to set each column for the row, than empty strings will be substituted.


What it looks like to me is your trying to insert headers in to the mlist


Code
  
my $searchRes = $top->DialogBox(-title => 'Search Results',
-buttons => ['OK', 'Cancel'],);
my @dispRes = qw(ID FirstName LastName); # your trying to add twice or have name clashes

my $ml = $searchRes->Scrolled(
qw/MListbox -selectmode single -scrollbars oe -font small /
)->pack(-expand => 1, -fill => 'both');

foreach my $colHdrs (@dispRes){
$ml->columnInsert('end',-text=>$colHdrs);
}

#### your adding already added column headers for data?
foreach (@dispRes){
push @row, $hash{$_}; <-- this is returned by another function, data dump shows no change.
}

$ml->insert('end', \@row);


This is what the insert takes if For a MListbox with four columns, the following would add three new rows


Code
$ml->insert("end", 
[qw/Row0:Col0 Row0:Col1 Row0:Col2 Row0:Col3/],
[qw/Row1:Col0 Row1:Col1 Row1:Col2 Row1:Col3/],
[qw/Row2:Col0 Row2:Col1 Row2:Col2 Row2:Col3/]
);



(This post was edited by wickedxter on Feb 12, 2013, 6:49 PM)


lightspd
Novice

Feb 13, 2013, 6:11 AM

Post #3 of 3 (659 views)
Re: [wickedxter] Tk and Tk::MListbox [In reply to] Can't Post

I'm using the column header names as keys for my hash.

If I leave see out, it will display the results, but you cannot select anything and if I click on the sort, everything clears. I found a similar problem with MListbox listed on another site, with a solution of replace SUPER in MListbox.pm with Tk::Listbox, but that didn't seem to change anything.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives