[Tkinter-discuss] Re: How to change font sizes in a Tkinter app?

stewart at midtoad.homelinux.org stewart at midtoad.homelinux.org
Sat Sep 11 05:53:33 CEST 2004

Quoting Michael Lange <klappnase at freenet.de>:

> maybe the easiest would be to put all the widgets that use the font in a list
> and then do something like:
> for widget in widgetlist:
>     widget.configure(font=newFont)
> when the user changes the font.

I want to change all my menu entries to use the new font.  But,I don't see how
to get the right name for those items to use in the list since each menu entry
doesn't have a discrete object name, like say a button would
(btn=Tkinter.Button, so you could have widgetlist=[btn,lbl,btn2].  I read
something about using component() to achieve this, but the exact implementation
escapes me - the example I saw related to notebook tabs rather than menu entries. 

> I think the usual way to do this is to use an option database which allows to
> override default tk options
> like fonts and colors (in case you want to change the default font for the
> whole app). Entries in an option database
> look like this:

thanks for this useful detail.   I'll give it a try on Monday.  I did try a
similar idea, putting the current font name into another module which I called
basefont.py.  I built a test app and was able to change the font this way (the
user has to quit and restart the app, but that's okay).   The strange thing is,
when I copy the methods into my real app, it doesn't work due to a scoping
problem in the lambda function I use. I'll post the details on that on Monday. 


More information about the Tkinter-discuss mailing list