# set a default font for all widgets $mw->optionAdd('*font', 'Arial 24'); #### #!/usr/bin/perl use warnings; use strict; use Tk; my $mw = new MainWindow(-bg =>'black'); # set a default font $mw->optionAdd('*font', 'Arial 24'); # a useful way of tagging fonts for special use $mw->fontCreate('big', -family=>'arial', -weight=>'bold', -size=> 38 ); # will use default font my $menubar = $mw->Menu(-type => 'menubar'); $mw->configure(-menu => $menubar); my $menu = $menubar->cascade(-label => '~File'); $menu->command(-label => '~New'); $menu->command(-label => '~Open'); $mw->Button(-text => 'test this font', -bg=>'white')->pack; $mw->Label(-text => 'test this font', -bg=>'lightyellow')->pack; my $text = $mw->Text(-bg=>'white', -height => 4, -width =>20)->pack; $text->insert('0.0','test this font'); my $canvas = $mw->Canvas(-bg=>'lightgreen')->pack; #make a special font my $font = $mw->Font(-family=> 'Arial', -size => 18); # will use default font $canvas->createText( 0, 0, -anchor => 'nw', -text => 'test this font', ); # special font $canvas->createText( 0, 50, -anchor => 'nw', -text => 'test this font', -font => $font, ); # tagged font $canvas->createText( 0, 100, -anchor => 'nw', -text => 'test this font', -font => 'big', ); MainLoop;