develooper Front page | perl.beginners | Postings from April 2002

accessing -lable value in cascade widget

From:
richard noel fell
Date:
April 29, 2002 06:32
Subject:
accessing -lable value in cascade widget
Message ID:
3CCD4F54.628CDA2A@rcn.com
Below is some sample code which I hope will illustrate the problem I am
facing.

#!/usr/local/ActivePerl-5.6/bin/perl5.6.1 -w
use Tk;
use Tk::Dialog;
use strict;

##################################################
my $mw = MainWindow->new;
use subs qw/file_menuitem/;
$mw->configure(-menu=>my $menubar=$mw->Menu);
my $file = $menubar->cascade(
			     -label => 'File', -menuitems=>file_menuitem);
print $file->cget(-label); # just to make sure I can  am using cget
correctly.
MainLoop;
# In the following subroutine, asssume I do not know  the -label value 
is 'Save' and that I want to print the -label value with the subroutine
#defined with -command, as perhaps in the following
sub file_menuitem{
	[
   ['command', 'Save', -command=>sub { print  whatever the -label value
is. \n"}],
   ]
}

How can I have the -command subroutine find out  the -label value,  I
have tried a number of things, all naive, and all of which did not work. 
Thanks for any help. This problem has really stumped me.
Dick Fell



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About