setting the font in Tkinter

jepler epler jepler.lnk at lnk.ispi.net
Sat Sep 16 17:06:26 EDT 2000


On Sat, 16 Sep 2000 01:47:11 GMT, Rick Pasotto <rickp at telocity.com>
wrote:
>>How do I set the default font for a window and all its widgets? The
>>system default is too small.

You should be able to use the 'option' tk command.  It's documented
(somewhat obscurely) in the tk manual.  In tk, this would be written
	option *Font {helvetica -24}  # Make most fonts Helvetica 24pt
	option *Button*Font {Times -24} # Make button fonts Times 24pt
and in Python you can write it:
	from Tkinter import *
	app = Tk()
	app.tk.call("option", "*Font", "Helvetica -24")
	app.tk.call("option", "*Button*Font", "Times -24")
The font selection will take effect for widgets created *after* the
tk calls.

I've only checked this on a Unix version of Python, but ISTR that this works
for Windows apps too.  Good luck!



More information about the Python-list mailing list