Control Font in tkMessageBox Control Font in tkMessageBox tkinter tkinter

Control Font in tkMessageBox


You can configure the font for just dialog boxes by doing the following:

from Tkinter import *import tkMessageBoxr = Tk()r.option_add('*Dialog.msg.font', 'Helvetica 12')tkMessageBox.showinfo(message='Hello')

(Only the option_add invocation is modified from the accepted answer.)


The following works here. You will need to change the second argument of option to the font type and font size you want.

 from Tkinter import * import tkMessageBox r = Tk() r.option_add('*font', 'Helvetica -12') tkMessageBox.showinfo(message='Hello')

You may have to call r.option_clear() to clear it afterwards.

See here for more information about setting the font of other Tkinter widgets.

This doesn't work with tkMessageBox because tkCommonDialog doesn't take the font option.


option_add may only work for linux operating systems, but you can control font, where the lines wrap, and the width of the box:

    root.option_add('*Dialog.msg.font', 'Helvetica 24')    root.master.option_add('*Dialog.msg.width', 34)    root.master.option_add("*Dialog.msg.wrapLength", "6i")