Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: How Can My Perl/Tk Program use a Defined Font for All Widgets?

by johngg (Canon)
on Dec 09, 2018 at 12:06 UTC ( [id://1227002]=note: print w/replies, xml ) Need Help??


in reply to How Can My Perl/Tk Program use a Defined Font for All Widgets?

I didn't know about the $mw->optionAdd('*font' => 'sans 12'); method, ++ tybalt89.

What I have been doing is to use fontCreate() to create a font for the main window then add that font to the options hashes that I apply when creating widgets.

my $mwFont = $mainWin->fontCreate( q{mwFont}, -family => q{courier}, -size => 10, ); $commonLabelOpts{ -font } = $mwFont; $commonButtonOpts{ -font } = $mwFont; $commonRadioButtonOpts{ -font } = $mwFont; ... $controlButtonFrame->Button( %commonButtonOpts, -text => q{Quit}, ...

The optionAdd() method seems simpler so I will most likely use it for new code.

Update: Changed example to correct the senior moment of choosing a widget without fonts ... what a dummy :-/

Cheers,

JohnGG

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-04-24 18:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found