12.07.2015 Views

Tkinter reference: A GUI for Python

Tkinter reference: A GUI for Python

Tkinter reference: A GUI for Python

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

is the author’s favorite fixed-width font <strong>for</strong> use in X windows. Use the xfontselprogram to help you select pleasing fonts.To get a list of all the families of fonts available on your plat<strong>for</strong>m, call this function:tkFont.families()The return value is a list of strings. Note: You must create your root window be<strong>for</strong>ecalling this function.These methods are defined on font objects:.actual ( option=None )If you pass no arguments, you get back a dictionary of the font’s actual attributes, whichmay differ from the ones you requested. To get back the value of an attribute, pass itsname as an argument..cget ( option )Returns the value of the given option..configure ( **options )Use this method to change one or more options on a font. For example, if you have aFont object called titleFont, if can call titleFont.configure ( family="times",size=18 ), that font will change to 18pt Times and any widgets that use that font willchange too..copy()Returns a copy of a Font object..measure ( text )Pass this method a string, and it will return the number of pixels of width that string willtake in the font. Warning: some slanted characters may extend outside this area..metrics ( *options )If you call this method with no arguments, it returns a dictionary of all the font metrics.You can retrieve the value of just one metric by passing its name as an argument. Metricsinclude:ascentNumber of pixels of height between the baselineand the top of the highest ascender.descentNumber of pixels of height between the baselineand the bottom of the lowest ascender.fixedThis value is 0 <strong>for</strong> a variable-width font and 1 <strong>for</strong> amonospaced font.linespaceNumber of pixels of height total. This is the leadingof type set solid in the given font.3.5 BitmapsFor bitmap options in widgets, these bitmaps are guaranteed to be available:The graphic above shows Button widgets with the standard bitmaps. From left to right,they are "error", "gray75", "gray50", "gray25", "gray12", "hourglass", "info","questhead", "question", and "warning".New Mexico Tech Computer Center <strong>Tkinter</strong> <strong>reference</strong>: Standard attributes Page 8

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!