Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Control Font in tkMessageBox

I would to like to control the font of the text on a tkMessageBox but I can't see any reference of such a stuff. Is it only implemented in Tkinter?

Thanks,

like image 475
lpostula Avatar asked Feb 19 '12 07:02

lpostula


People also ask

How to change MessageBox size in Tkinter?

By Changing ReadMe Filetxt the length of the content of the readme file determines the size of the messagebox.

How do you change the size of a box in Python?

Steps. Set the figure size and adjust the padding between and around the subplots. Make a Pandas dataframe, i.e., two-dimensional, size-mutable, potentially heterogeneous tabular data. Make a box and whisker plot, using boxplot() method with width tuple to adjust the box in boxplot.


2 Answers

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')
tkMessageBox.showinfo(message='Hello')

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

like image 189
Charl Botha Avatar answered Oct 07 '22 11:10

Charl Botha


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.

like image 25
Appleman1234 Avatar answered Oct 07 '22 11:10

Appleman1234