merrymonk has asked for the wisdom of the Perl Monks concerning the following question:
Help would be much appreciated!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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tabbed Frame - Raise & Disable Query
by Anonymous Monk on Aug 25, 2009 at 11:13 UTC | |
by $self (Friar) on Aug 25, 2009 at 12:09 UTC | |
by merrymonk (Hermit) on Aug 25, 2009 at 11:22 UTC |