I am sure that this should be simple but after some time looking at it I cannot see what is wrong !
I have set up a tabbed frame and using the –caption option given it a ‘title’.
I then try to:
1. Retrieve this but nothing is returned;
2. Reset it using configure but get the message that –caption is not an option.
Can someone give me a clue as to why this is wrong.
The Perl and full output is given below.
# tabframe-m
use strict "vars";
use Tk;
use Tk::TabFrame;
my ($a_tbfr, $tab_mw, $b_tbfr, $frame_wg, %lbwg, %entrywg);
my ($label_text, $CurrentSelection, $child, $childb, $childc, $childd)
+;
my ($CurrentSelectionC, $CurrentSelectionR, %tabwg, $tabwg_item, $curr
+ent_product, $gen_str);
my ($gen_intials, $gen_str, $gen_whog, $gen_whoa, $gen_whob, $gen_whoc
+, $pb_intials, $pa_intials, $pb2_intials, $j, $j_str);
my ($lb_str, $en_str, $cap_retrieved, $lab_retrieved, $lb_text, $text_
+retrieved, $top_wg);
$current_product = 'unset';
$tab_mw = MainWindow->new;
$top_wg = $tab_mw->Label(-text => 'Caption query')->grid(-row => 0);
$text_retrieved = $top_wg->cget(-text);
print "top_wg $top_wg retrieved text $text_retrieved\n";
$a_tbfr = $tab_mw->TabFrame
(
-font =>'-adobe-times-medium-r-bold--14',
-tabcurve =>4,
-padx => 10,
-pady => 10,
-width => 50
);
$a_tbfr->grid ('-row' => 1);
for($j = 1; $j <= 1; $j ++) {
$j_str = "Tab " . $j;
# this sets the caption which can be seen
$tabwg{$j_str} = $a_tbfr->Frame
(
-caption => $j_str,
);
# this trys to retrieve the caption but nothing is returned
$cap_retrieved = $tabwg{$j_str}->cget( -caption);
print "widget name $j_str wg $tabwg{$j_str} caption set $j_str ret
+rieved [$cap_retrieved]\n";
$lb_str = "Tab " . $j . '_Label';
$lb_text = "Text in Label in $j_str";
$lbwg{$j_str} = $tabwg{$j_str}->Label(-text => $lb_text,
-width => 100)->grid(-row => 2, -column=>0);
$lab_retrieved = $lbwg{$j_str}->cget( -text);
print "text given $lb_text wg $tabwg{$j_str} retrieved $lab_retrie
+ved\n";
$en_str = "Tab " . $j . '_Entry';
$tabwg{$j_str}->Entry (-text => $en_str,
-width => 20)->grid(-row => 3, -column=>0);
}
foreach $tabwg_item (keys %tabwg) {
print "item $tabwg_item wg $tabwg{$tabwg_item}\n";
# this trys to reset the caption for the tabbed frame child
$tabwg{$tabwg_item}->configure(-caption => 'New Caption');
}
print "\n";
MainLoop;
Contents of MS-DOS screen
top_wg Tk::Label=HASH(0x194b508) retrieved text Caption query
widget name Tab 1 wg Tk::Frame=HASH(0x1a89968) caption set Tab 1 retrieved []
text given Text in Label in Tab 1 wg Tk::Frame=HASH(0x1a89968) retrieved Text in Label in Tab 1
item Tab 1 wg Tk::Frame=HASH(0x1a89968)
Tk::Error: Can't set -caption to `New Caption' for Tk::Frame=HASH(0x1a89968): unknown option "-caption" at C:/.../perl5/site/lib/Tk/Configure.pm line 45.
at C:/.../perl5/site/lib/Tk/Derived.pm line 294
Tk callback for event
Tk callback for .
Tk callback for .tabframe.buttonFrame
Tk callback for .tabframe.magicFrame
Tk callback for .tabframe
Tk callback for .tabframe
Tk callback for .tabframe.tabChildFrame
Tk callback for .tabframe.tabChildFrame.frame
Tk callback for .tabframe.buttonFrame.button_Tk_Frame_HASH_0x1a89968_
Tk callback for .tabframe
Tk callback for .tabframe.buttonFrame.button_Tk_Frame_HASH_0x1a89968_.frame
Tk callback for .tabframe.buttonFrame.button_Tk_Frame_HASH_0x1a89968_.frame1
Tk callback for .tabframe.buttonFrame.button_Tk_Frame_HASH_0x1a89968_.frame2
Tk callback for .tabframe.buttonFrame.button_Tk_Frame_HASH_0x1a89968_.frame3
Tk callback for .tabframe.buttonFrame.button_Tk_Frame_HASH_0x1a89968_.frame4
Tk callback for .tabframe.buttonFrame.button_Tk_Frame_HASH_0x1a89968_.frame5
Tk callback for .tabframe.tabChildFrame.frame
Tk callback for .tabframe.tabChildFrame.frame
Tk::Derived::configure at C:/.../perl5/site/lib/Tk/Derived.pm line 306
Can't set -caption to `New Caption' for Tk::Frame=HASH(0x1a89968): unknown option "-caption" at C:/.../perl5/site/lib/Tk/Configure.pm line 45.
at C:/.../perl5/site/lib/Tk/Derived.pm line 294