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

Martin Franklin mfranklin1 at gatwick.westerngeco.slb.com
Tue Sep 14 16:58:16 CEST 2004


On Tue, 14 Sep 2004 08:12:51 -0500, Jeff Epler <jepler at unpythonic.net>  
wrote:

> I had intended to send this to the list, but I didn't.
>
> ----- Forwarded message from Jeff Epler <jepler at unpythonic.net> -----
> Date: Tue, 14 Sep 2004 06:54:29 -0500
> From: Jeff Epler <jepler at unpythonic.net>
> To: stewart at midtoad.homelinux.org
> Subject: Re: How to change font sizes in a Tkinter app?
>
> My menu manpage says this about menus on Windows:
>        When  Tk  sees  a System menu on Windows, its items are appended  
> to the
>        system menu that the menubar is attached to. This menu has an  
> icon rep-
>        resenting  a  spacebar,  and can be invoked with the mouse or by  
> typing
>        Alt+Spacebar.  Due to limitations in the Windows API, any font  
> changes,
>        colors,  images, bitmaps, or tearoff images will not appear in  
> the sys-
>        tem menu.
> maybe this limitation applies to all menus, or the initial -font
> setting cannot change, or there is some OS-specific limitation that is
> not documented.  This is the price you pay for a native-looking menu
> on Windows...
>
> I just ran this on Windows XP SP2, Python 2.3, Tk 8.4 and indeed my
> program doesn't work---the font doesn't change size.  But neither does
> setting a font in the first place.  When the menu with entry fonts set
> is posted by a menubutton, I get that font on Windows.
>     mb = Tkinter.Menubutton(t, text="Menu")
>     mbm = Tkinter.Menu(mb)
>     mbm.insert_cascade("end", label="File", underline=0,  
> font=("Helvetica", 24))
>     mbm.insert_cascade("end", label="Edit", underline=0)
>     mbm.insert_cascade("end", label="Help", underline=0)
>     mb.configure(menu=mbm)
>     mb.pack(side="left")
>

Above does work - but I thought we were supposed to move away from  
Menubutton's

(Can't remember where I read that though)


> So I guess that items on the main menu bar have the same caveat as those
> on the System menu.  It's unfortunate that this isn't documented by the
> Tk folks.
>


Sorry Jeff not sure I follow are you saying this :

import Tkinter

t = Tkinter.Tk()
mb = Tkinter.Menu(t)
mbm = Tkinter.Menu(mb)
mbm.insert_cascade("end", label="File", underline=0, font=("Helvetica",  
24))
mbm.insert_cascade("end", label="Edit", underline=0)
mbm.insert_cascade("end", label="Help", underline=0)
t["menu"] = mb

mb.add_cascade(menu=mbm, label="Menu")
t.mainloop()


does not show a different font on your Windows system?























> Jeff
> ----- End forwarded message -----



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



More information about the Tkinter-discuss mailing list