dynamically creating labentry widgets with a subroutine and getting right textvariable out
am 17.10.2007 23:37:34 von ben.rogersHowdy,
I have a few LabEntry widgets that do similar things so I thought I
would create them with a sub and pass params to it. As you can see, I
pass filetypes4bin to the sub and it displays the list of file types
ok. However, when the user edits the entry field --say to add a few
more filetypes to look for--the textvariable is not updated.
1: How do I get the user modified textvariable out of the sub.
2: How do I keep the params I pass from breaking validatecommand.
$_[1] use to work for checking user input, but now of course it's
getting the value of the label param.
thanks,
ben
$filetypes4bin = "gif|jpg|bmp";
createLabEntryForFileTypes($dircleanPanelToolsSub1, "Pipe-separated
list of file types:", $filetypes4bin);
# Parent, title, textvariable.
sub createLabEntryForFileTypes{
my $parentwidget = $_[0];
my $label = $_[1];
my $filetypes = $_[2];
$parentwidget -> LabEntry(
-label => $label,
-labelPack => [ "-side" => "left" ],
-textvariable => $filetypes,
-width => 50,
-background => 'white',
-validate => 'key',
-validatecommand => sub { $_[1] =~ /\w/i },
-invalidcommand => sub { $mw -> bell })
->pack(-side => 'bottom', -pady => 6);
&stdMsg ("Selected filetypes: $filetypes");
return $filetypes;
}
# aardvark!