Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: increase font size in Perl TK

by cmv (Chaplain)
on Apr 26, 2016 at 18:19 UTC ( [id://1161577]=note: print w/replies, xml ) Need Help??


in reply to increase font size in Perl TK

Hi Monks-

++mikepol for asking
++zentara for his answer (and all his much appreciated pTk expertise over the years)

I know this is an old thread, but just had a similar question and could not find a suitable answer anywhere (on-site or off-site).

After banging my head against things for long enough, I came up with this solution. Hopefully, it will help others in the future.

-Craig

use strict; use warnings; use Tk; use Tk::Text; use Tk::Font; use Data::Dumper; # Create pTk text window... my $mw = MainWindow->new(-title => 'Text Font'); my $txt = $mw->Scrolled('Text')->pack(-fill => 'x', -side => 'left'); # Get Current font... my $currfont = $txt->cget(-font); # Create new font by cloning & modifying current font... my $boldfont= $currfont->Clone(-weight=>'bold'); # configure new tag ('bold') causing tagged characters to use the new +bold font... $txt->tagConfigure('bold', -font => $boldfont); # Insert some text that is not tagged as bold... $txt->insert('end', "========================\n"); $txt->insert('end', "Default font requested:\n" . Dumper($currfont)); $txt->insert('end', "\nDefault font chosen:\n" . Dumper($currfont->act +ual)); # Insert some text that is tagged as bold... $txt->insert('end', "========================\n"); $txt->insert('end', "Bold font requested:\n" . Dumper($boldfont), ['bo +ld']); $txt->insert('end', "\nBold font chosen:\n" . Dumper($boldfont->actual +), ['bold']); MainLoop;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1161577]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-20 00:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found