Control Font in tkMessageBox

前端 未结 3 1610
失恋的感觉
失恋的感觉 2021-01-12 04:20

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,

3条回答
  •  攒了一身酷
    2021-01-12 05:01

    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.

提交回复
热议问题