On Mon, Nov 22, 2010 at 3:21 PM, <pyt...@bdurham.com> wrote: > Is there a simple way to change the font style of widgets without explictly > knowing the widget's font? > > For example: if I want to toggle the bold state of a widget's text, do I > need to determine its font, then build an equivalent font object/expression > with the font style I need, and pass that full font description to > widget.config() or can I use a shortcut technique that allows me to pass > 'bold' or 'normal' to control a widget's font. >
Label(root, text='Font fun', font=('Arial', 100, 'bold')).config()['font'] returns a tuple - and since you can't modify a tuple, you'll have to determine the current font. There may be a shorter way, but here's what you can do: mylabel.config(font=mylabel.config()['font'][4][:2] + ('normal',)) mylabel.config(font=mylabel.config()['font'][4][:2] + ('bold', 'italics')) And that should work. HTH, Wayne
_______________________________________________ Tkinter-discuss mailing list Tkinter-discuss@python.org http://mail.python.org/mailman/listinfo/tkinter-discuss