[Tkinter-discuss] Change the font style (bold, italic, stikethru, normal) of widgets without explictly knowing font?

python at bdurham.com python at bdurham.com
Tue Nov 23 01:27:25 CET 2010


Hi Michael,

> If you don't explicitely define the label's font, the font is a string (at least here, on linux):
> >>> from Tkinter import *
> >>> l=Label(text='foo')
> >>> l.pack()
> >>> l.cget('font')
> 'Helvetica -12 bold'

I get strings as well (32-bit Python 2.7 under Windows 7).

> If you want to do fancy things with fonts, I'd try tkFont, with a tkFont.Font() you can easily configure all kinds of font attributes.

I agree with you - tkFont is definitely the way to go.

Thank you,
Malcolm


More information about the Tkinter-discuss mailing list