Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Tk::Notebook 'unkown tab'

by dimmesdale (Friar)
on Jul 22, 2002 at 13:16 UTC ( [id://184029] : perlquestion . print w/replies, xml ) Need Help??

dimmesdale has asked for the wisdom of the Perl Monks concerning the following question:

I'm working with Tk again creating a GUI, and decided the Tk::NoteBook was what I needed. However, it's giving me some problems. For one, I get Tk::Button=Hash(hex#) is not a Tk Object ... and also, Tk::Error: Unkown tab "page0" (several times).

I get the latter one just by including an $notebook->add('something', options) statement (which the docs say is how you get a tab).

Here's the relavent portion, thanks for any help ...

my $nb = $mw->NoteBook->grid; for(0..$num-1) { my $page = $nb->add("Page$_", -text => "Name$_"); my $ne = $page->Entry( -textvariable => \$info->[$_]->{name}, ); my $ie = $page->Entry( -textvariable => \$info->[$_]->{index}, ); my $pom = $page->Optionmenu( -variable => \$info->[$_]->{parser}, -options => [@parsers], ); my $gom = $page->Optionmenu( -variable => \$info->[$_]->{graph}, -options => [@graphs], ); my $rcb = $page->Checkbutton( -text => 'Rare Event', -variable => \$info->[$_]->{rareevent}, ); my $dom = $page->Optionmenu( -variable => \$info->[$_]->{subdir}, -options => [@subdirs], ); my $fom = $page->Optionmenu( -variable => \$info->[$_]->{file}, -options => get_files($info->[$_]->{subdir}), ); my $b = $page->Button( -text => 'Set', -command => [\&record, {}], ); my @grid = (); if($name) { push @grid, \$ne} if($index) { push @grid, \$ie} if($parser) { push @grid, \$pom} if($graph) { push @grid, \$gom} if($rareevent) { push @grid, \$rcb} push @grid, (\$dom, \$fom, \$b); my $first = shift @grid; my $args = join(',', @grid); $$first->grid( eval $args );

Replies are listed 'Best First'.
Re: Tk::Notebook 'unkown tab'
by Abigail-II (Bishop) on Jul 22, 2002 at 14:09 UTC
    Your my $args  = join(',', @grid); is stringifying everything inside @grid, including all the objects. The grid widgit manager expects a list of objects, not whatever comes out the the eval. I think you want: $$first -> grid (@grid), but it's hard to say something with substance of a code fragment that can't be run standalone.


      fixed it... never mind.

      For the curious, I used a -text option, as I saw on the docs for notebook, however I saw someone else use -label, and upon changing it the code worked. Go figure