Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verbose font specification does not work #27

Open
hakonhagland opened this issue Mar 29, 2017 · 1 comment
Open

Verbose font specification does not work #27

hakonhagland opened this issue Mar 29, 2017 · 1 comment

Comments

@hakonhagland
Copy link

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.

@eserte
Copy link
Owner

eserte commented Nov 11, 2017

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants