setting the font in Tkinter
Rick Pasotto
rickp at telocity.com
Sun Sep 17 08:51:28 EDT 2000
On Sat, 16 Sep 2000 21:06:26 GMT in comp.lang.python, jepler epler wrote:
> 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!
This didn't work for me on linux. I got from the traceback:
root.tk.call("option","*Font","Helvetica -24")
TclError: bad option "*Font": must be add, clear, get, or readfile
--
"The market is not an invention of capitalism. It has
existed for centuries. It is an invention of civilization."
-- Mikhail Gorbachev
Rick Pasotto email: rickp at telocity.com
More information about the Python-list
mailing list