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!

In reply to Tabbed Frame - Raise & Disable Query by merrymonk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.