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

Using tabbed frames I want:
a) to know which tabbed frame is raised;
b) to be able to raise a tabbed frame;
c) to be able to disable a tabbed frame.
The attached Perl tries to do these three things but only succeeds with the first.
There are three buttons that try to raise the widgets and three buttons that try to disable the widgets.
There is a print statement in the raise button that gives
Raise General - result <> for <Tk::Frame=HASH(0x1a63a30)>
where in the <> is the result of the raise attempt.
Does the failure mean that the call is wrong or is it something else?
Using the disable button I get the following error
Tk::Error: Failed to AUTOLOAD 'Tk::Frame::disable' at ….directory/tabframe-raise-query.pl line 115
Carp::croak at …directory/Carp.pm line 269
Tk::Widget::__ANON__ at …directory/Widget.pm line 347
main::__ANON__ at ….directory\tabframe-raise-query.pl line 115
Tk callback for .button3
Tk::__ANON__ at…directory/Tk.pm line 247
Tk::Button::butUp at directory/Button.pm line 111
<ButtonRelease-1>
(command bound to event)
Does this simply mean I have to load a specific Perl module or is it something else?
use strict "vars"; use Tk; use Tk::TabFrame; my ($a_tbfr, $tab_mw, $b_tbfr, $frame_wg); my ($label_text, $CurrentSelection, $child, $childb, $childc, $childd) +; my ($CurrentSelectionC, $CurrentSelectionR, %tabwg, $tabwg_item, $rais +ed_wg, $raised_str, $raised_res); my ($butrg, $butrb, $butrc, $butdg, $butdb, $butdc); $tab_mw = MainWindow->new; $tab_mw->Label(-text => 'Tabbed Frame to Check Raising')->grid(-row => + 0); $a_tbfr = $tab_mw->TabFrame ( -font =>'-adobe-times-medium-r-bold--14', -tabcurve =>4, -padx => 10, -pady => 10, -width => 400 ); $a_tbfr->grid ('-row' => 1); $raised_wg = $tab_mw->Label(-text => '')->grid(-row => 2); # create the three tabbed frames $child = $a_tbfr->Frame ( -caption => 'General', -tabcolor => 'yellow', -width => 400 ); $tabwg{$child} = "General"; $child->Label(-text => 'Text in Label in 1st Frame of Tabbed Frame')-> +grid(-row => 2, -column=>0); $childb = $a_tbfr->Frame ( -caption => 'Product A', -tabcolor => 'red', -width => 400 ); $tabwg{$childb} = "Product A"; $childb->Label(-text => 'Text in Label in 2nd Frame of Tabbed Frame')- +>grid(-row => 1); $childc = $a_tbfr->Frame ( -caption => 'Product B (pg 1)', -tabcolor => 'blue', -width => 400 ); $childc->Label(-text => 'Text in Label in 3rd Frame of Tabbed Frame')- +>grid(-row=>1); $tabwg{$childc} = "Product B"; # set up bind for any key and mouse button usage - this always shows w +hich tabbed frame is raised $tab_mw->bind("<KeyPress>", [sub { print "[KeyPress] main key press\n"; }]); $tab_mw->bind("<ButtonRelease>", [sub { print "[ButtonPress] main button release\n"; $CurrentSelectionC = $a_tbfr->cget ('-current'); $CurrentSelectionR = $a_tbfr->cget ('-raised'); print "CurrentSelection C <$tabwg{$CurrentSelectionC}> R <$tabwg{$ +CurrentSelectionR}>\n"; $raised_str = "Raised tabbed frame is $tabwg{$CurrentSelectionC}"; $raised_wg->configure(-text => $raised_str); }]); # buttons to raise widgets $butrg = $tab_mw->Button(-text => "Raise General", -command => sub { $raised_res= $child->raise(); print "Raise General - result <$raised_res> for <$ +child>\n"; } ) ->grid(-row => 3, -column => 0); $butrb = $tab_mw->Button(-text => "Raise Product A", -command => sub { $raised_res= $childb->raise(); print "Raise Product A - result <$raised_res> for +<$childb>\n"; } ) ->grid(-row => 3, -column => 1); $butrc = $tab_mw->Button(-text => "Raise Product B", -command => sub { $raised_res= $childc->raise(); print "Raise Product B - result <$raised_res> for +<$childd>\n"; } ) ->grid(-row => 3, -column => 2); # buttons to disable widgets $butdg = $tab_mw->Button(-text => "Disable General", -command => sub { $raised_res= $child->disable(); print "Disable General - result <$raised_res>\n"; } ) ->grid(-row => 4, -column => 0); $butdb = $tab_mw->Button(-text => "Disable Product A", -command => sub { $raised_res= $childb->disable(); print "Disable Product A - result <$raised_res>\n" +; } ) ->grid(-row => 4, -column => 1); $butdc = $tab_mw->Button(-text => "Disable Product B", -command => sub { $raised_res= $childc->disable(); print "disable Product B - result <$raised_res>\n" +; } ) ->grid(-row => 4, -column => 2); #print the widget values of the tabbed frames foreach $tabwg_item (keys %tabwg) { print "item <$tabwg_item> wg <$tabwg{$tabwg_item}>\n"; } print "\n"; MainLoop;
Help would be much appreciated!

Replies are listed 'Best First'.
Re: Tabbed Frame - Raise & Disable Query
by Anonymous Monk on Aug 25, 2009 at 11:13 UTC
    Does this simply mean I have to load a specific Perl module or is it something else?

    It means Tk::Frame does not have a disable method. Where did you get idea for disable method?

    Tk::TabFrame has had no updates since February 2, 1999.

      >Tk::TabFrame has had no updates since February 2, 1999.

      Indeed, better use DynaTabFrame.

      I just hoped there may be a disable method and therefore tried!