How to set font of a messagebox with Python tkinter?


I’m using the simple message-boxes provided in tkinter and I’m wondering if there’s any way to change the font.

This is the general idea of what I want, but the font= option doesn’t work.

from tkinter import Tk
import tkinter.messagebox as tkmsg

_root = Tk()
    "Some monospaced text",
    font=("Monospace", 15)

Is there any way to change the font or do I have to use a custom dialog?

Asked By: kiri



You should write your own messagbox. Tkinter invoke system dialog for Windows or Mac and genetate dialogs for Linux. In all cases is imposible change Tkinter dialogs.

Answered By: Michael Kazarian

you can’t.
write your own messagebox using the toplevel widgted (tkinter.Toplevel()) and label!

Something like this (from

from Tkinter import *

master = Tk()

w = Label(master, text="Hello, world!")


i hope it helps!

Edit: This is a very old answer, 3 years later someone said it’s possible:
Control Font in tkMessageBox

Answered By: Lucas Sabião

See here for how to change the dialog box text: Control Font in tkMessageBox

In short (copied verbatim from the link above):

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

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

Be sure to call r.option_clear() to set the font back to normal afterwards.

Answered By: Gabriel Staples

You can change the default font for captions:

import tkinter as tk
from tkinter import messagebox as mb
from tkinter import font
root = tk.Tk() 
font1 = font.Font(name='TkCaptionFont', exists=True)
font1.config(family='courier new', size=20)
Answered By: cyberthanasis
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.