[Tkinter-discuss] Font control in tkMessageBox?

Stewart Midwinter stewart.midwinter at gmail.com
Wed Apr 13 17:37:36 CEST 2005

On 4/13/05, Michael Lange <klappnase at web.de> wrote:
> you can specify an application-wide default font which will be used by tkMessageBox , too.
> >>> from Tkinter import *
> >>> import tkMessageBox
> >>> r = Tk()
> >>> r.option_add('*font', 'Helvetica -12')
> >>> tkMessageBox.showinfo(message='Hello')

This seems to have no effect under WindowsXP. 

If I use a different widget, I do get the font to be set, but only if
I add the following line before instantiating my widget:
also, you have to explicitly create your file optionDB before you run
your app.  The following example does show colours and fonts set:

from Tkinter import *
import tkMessageBox, os
optionFile = 'optionDB'
if not os.path.exists(optionFile):
    f1 = open(optionFile,'r')
r = Tk()

r.option_add('*font', ('Courier 6 italic'))

tkMessageBox.showinfo(message='Hello, World!')
l = Label(r, text = "What colour am I?")
b = Button(r, text = "Quit Now!", command= sys.exit)

Stewart Midwinter
stewart at midwinter.ca
stewart.midwinter at gmail.com
Skype: midtoad

More information about the Tkinter-discuss mailing list