Get Tk::FontDialog, it has a real nice FontDialog, and a way to apply the font to your whole window.
#!/usr/bin/perl use Tk; use Tk::FontDialog; $top=new MainWindow; my $fd; $b = $top->Button(-text => 'Choose Font', -command => sub { $font = $fd->Show; apply_font($font); })->pack; $f = $top->Frame->pack; $f->Label(-text => 'Test RefontTree 1')->pack; $f2 = $f->Frame->pack; $f2->Label(-text => 'Test RefontTree 2')->pack; $c = $f2->Canvas(-width => 100, -height => 30)->pack; $c->createText(0,0,-anchor => 'nw', -text => 'Canvas Text'); $fd = $top->FontDialog(-nicefont => 0, -title => 'Select Font', -applycmd => \&apply_font, -familylabel => 'Schrift~familie', -fixedfontsbutton => 1, -nicefontsbutton => 1, ); $bf = $top->Frame->pack; $bf->Button(-text => 'OK', -command => sub { print "ok $ok\n"; $top->destroy;})->pack(-side => 'left'); $bf->Button(-text => 'Not OK', -command => sub { print "not ok $ok\n"; $top->destroy;})->pack(-side => 'left'); MainLoop; sub apply_font { my $font = shift; if (defined $font) { $b->configure(-font => $font); $f->RefontTree(-font => $font, -canvas => 1); } }
In reply to Re: Chinese font problem in Perl/Tk
by zentara
in thread Chinese fonts problem in Perl/Tk
by shockers
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |