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

Martin Franklin mfranklin1 at gatwick.westerngeco.slb.com
Tue Sep 14 18:52:45 CEST 2004

On Tue, 14 Sep 2004 17:26:59 +0100, Martin Franklin  
<mfranklin1 at gatwick.westerngeco.slb.com> wrote:

> On Tue, 14 Sep 2004 09:10:48 -0600, <stewart at midtoad.homelinux.org>  
> wrote:
>> Quoting Martin Franklin <mfranklin1 at gatwick.westerngeco.slb.com>:
>>> I got your code running good work!  However it doesn't update the fonts
>> Now this gets curioser and curioser.  When I add your code in, the  
>> top-level
> Unchanged your code does update the font of the Menu-bars items
> (I.E The words "File" + "Options") but not the menu items.
> I just had a thought perhaps it's a different Pmw version..... ahhh
> yes I've got an old 0.8.3 Pmw Bundle in my dumping ground directory!
> This version of Pmw uses Menubuttons (under the covers|) perhaps the
> latest is different...
> I will need to download and install (should have done that years ago)
> Incidentally I am also using Python 2.3.4 - I Must have upgraded in my
> sleep ;-)
> Will let you know after the upgrade...

Well now I'm stumped... really running your code unchanged with Python  
on Windows 2000 with Pmw 1.2 it only changes the Toplevel Menu Font
"File" and "Options" none of the menu items change font at all

Then, again unchanged, using update2 method does the oposite - it changes
the fonts of all the menu items but not the toplevel menu's themselves

Now I put the update code into the update2 method (as I think it was in
my earlier reply) and it changes all fonts for all menu's and all menu

Lets call it update3 ;-)

     def update3(self, widget):
             widget["font"] = self.newFont[self.size]
             # for each menu item try setting the font
             for i in range(widget.index("end") + 1):
                 t = widget.type(i)
                 ## unless it's a tearoff or separator
                 if t in ("tearoff", "separator"):
                 widget.entryconfigure(i, font=self.newFont[self.size])

I had a quick look at the Pmw source code for it's MenuBar and it still
uses Menubutton under the covers, however I noticed a MainMenuBar mega
widget that does not...  I think part of all the confusion lies with
the Menubutton vs Menu widget in Tkinter...  As I said in an earlier
post I thought Menubutton was depricated - I can't remember when or
where I read that - I thought it was in Guido's old tkinter demo code
that used to ship with the python source code (anyone got an old distro?)
but my memory's not what it used to be (2 kids will do that to a man)

Clear as mud ;-)


Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

More information about the Tkinter-discuss mailing list