| 1 |
#!/usr/local/bin/perl -w |
| 2 |
use Tk; |
| 3 |
use Tk::X11Font; |
| 4 |
use Tk::ROText; |
| 5 |
|
| 6 |
my $mw = MainWindow->new; |
| 7 |
my $font = $mw->X11Font(space => 'm', |
| 8 |
weight => 'medium', |
| 9 |
point => 140); |
| 10 |
my $mb = $mw->Frame->pack(-fill => 'x'); |
| 11 |
my $text = $mw->ROText(-font => $font)->pack(-expand => 1, -fill => 'both'); |
| 12 |
my $bfont = $font->Clone(weight =>'bold'); |
| 13 |
my $bold = $text->Tag('bold',-font => $bfont); |
| 14 |
|
| 15 |
print "Bold is ",scalar($bfont->Name),"\n ascent=", |
| 16 |
$bfont->ascent," descent=",$bfont->descent,"\n"; |
| 17 |
|
| 18 |
$mb->Optionmenu(-text => 'Font', -underline => 0, |
| 19 |
-options => [sort $font->Name], |
| 20 |
-command => [configure => $text, '-font' ]) |
| 21 |
->pack(-side => 'right'); |
| 22 |
$mb->Button(-text => 'Quit', -command => [destroy => $mw ])->pack(-side => 'left');; |
| 23 |
my $file = __FILE__; |
| 24 |
open(FILE,"<$file") || die "Cannot open $file:$!"; |
| 25 |
while (<FILE>) |
| 26 |
{ |
| 27 |
$text->insert(end => $_); |
| 28 |
} |
| 29 |
|
| 30 |
$text->bind('<b>',[$bold,'add',Ev('index' => 'sel.first'),Ev('index' => 'sel.last')]); |
| 31 |
|
| 32 |
MainLoop; |