#!/usr/bin/perl use strict; use warnings; use Tk; use Tk::Font; use Data::Dumper; printf "The version of Tk is '%s'\n", $Tk::VERSION; printf "The version of Tk::Font is '%s'\n", $Tk::Font::VERSION; make_gui(); MainLoop(); sub make_gui { # Main application window. my $mw = new MainWindow; # Create the font my @fontopts = (-family => 'Times', -size => 12, -weight => 'bold'); my $font = $mw->fontCreate(@fontopts); my $psubfonts = $mw->font('subfonts', $font); print Data::Dumper->new([$mw->fontActual($font), $psubfonts], [qw()])->Indent(1)->Useqq(1)->Dump; my $phello = sub { print "Hello\n" }; my $fr = $mw->Frame()->pack(); print "Creating button 1...\n"; $fr->Button(-text=>"B1", -command=>$phello,-font=>$font)->pack(); print "Creating button 2...\n"; $fr->Button(-text=>"B2", -command=>$phello,-font=>$font)->pack(); print "Creating button 3...\n"; $fr->Button(-text=>"B3", -command=>$phello, -font=>$font)->pack(); }