gri6507 has asked for the wisdom of the Perl Monks concerning the following question:
I think I am just misinterpreting the Data::Dumper output, but I can't see how. I am trying to add contents to a page in a Tk::NoteBook, with just using the reference to the notebook and a page number. Here's my code ...
The error I get isuse strict; use Tk; use Tk::NoteBook; my $mw = MainWindow->new; my $notebook = $mw->NoteBook()->pack(-expand=>1, -fill =>'both', -side +=>'right'); $mw->Button(-text=>'Click me', -command=> sub {AddAPage(\$notebook)})- +>pack(); MainLoop; sub AddAPage { my $n = shift; my @pages = $$n->info('pages'); my $pageNumber = scalar(@pages)+1; $$n->add($pageNumber, -label=>"hello $pageNumber"); AddPageContents($n,$pageNumber); } sub AddPageContents { my $n = shift; my $page = shift; use Data::Dumper; print Dumper($$n); $$n{_pages_}{$page}->Button(-text=>'Hi')->pack(); }
Tk::Error: Not a HASH reference at try.pl line 30. main::AddPageContents at try.pl line 30 main::AddAPage at try.pl line 20 main::__ANON__ at try.pl line 10 [\&main::__ANON__] Tk callback for .button Tk::__ANON__ at /usr/local/ActivePerl-5.6/lib/site_perl/5.6.1/sun4-so +laris-thread-multi/Tk.pm line 217 Tk::Button::butUp at /usr/local/ActivePerl-5.6/lib/site_perl/5.6.1/su +n4-solaris-thread-multi/Tk/Button.pm line 111
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tk::NoteBook references
by Crackers2 (Parson) on Aug 02, 2004 at 17:41 UTC |