You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According Matering Perl/Tk, Chapter 3 one can use a verbose font specification when calling configure on a widget. However, the following does not work:
use feature qw(say);
use strict;
use warnings;
use Tk;
use Tk::BrowseEntry;
my $mw = MainWindow->new(-title => 'Font test');
my $f = $mw->Frame->pack(-side => 'top');
my $family = 'Courier';
my $size = 24;
my $bentry = $f->BrowseEntry(
-label => 'Size:',
-variable => \$size,
-browsecmd => \&resize_font
)->pack(-side => 'left');
$bentry->insert('end', (3 .. 32));
my $sample = $mw->Entry(-textvariable => "Sample text")->pack(-fill => 'x');
resize_font();
MainLoop;
sub resize_font {
say "Setting new size: $size";
#$sample->configure( -font => "$family $size" ); # <--- CASE 1
#$sample->configure( -font => [ $family, $size ] ); # <--- CASE 2
$sample->configure(
-font => [ -family => $family, -size => $size ] # <--- CASE 3
);
}
when running this script, the font of the $sample Entry is never resized. However, the less verbose forms in CASE 1 and CASE 2 works fine. I could not find this behavior documented in Tk::Font either.
The text was updated successfully, but these errors were encountered:
I think the book was written around 2002, and at this time Tk was at version 800. Maybe these feature got lost during the transition to Tk 804. Probably it could be checked by building Tk 800...
According Matering Perl/Tk, Chapter 3 one can use a verbose font specification when calling
configure
on a widget. However, the following does not work:when running this script, the font of the
$sample
Entry is never resized. However, the less verbose forms in CASE 1 and CASE 2 works fine. I could not find this behavior documented in Tk::Font either.The text was updated successfully, but these errors were encountered: