faqts : Computers : Programming : Languages : Python : Tkinter

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

28 of 31 people (90%) answered Yes
Recently 9 of 10 people (90%) answered Yes

Entry

How do I set the default font for a window and all its widgets?

Nov 19th, 2008 21:44
Chris Zate, unknown unknown, Paul Magwene


You can set application wide defaults very easily in Tkinter.  The
following is from John Grayson's excellent book, Python and Tkinter
programming (you NEED this book if you want to do any really portable
Python GUI work):
-- Create a file called optionDB (or any other name you'd like) in the
same directory as your source code.  This file is a simple text file
specifying defaults (like the .Xdefaults file on X windows). E.g. (taken
directly from Grayson):
*font:          Verdana 10
*Label*font:    Verdana 10 bold
*background:    Gray80
*Entry*background: white
This will set the application wide default to Verdana, 10 pt, except for
lables which will use a bold version of the font.  The other options
should be self explanatory.
Then in your sourcecode do something like:
root = Tk()
root.option_readfile('optionDB')
http://animaux.leblogguide.com/
http://voyagesingapour.leblogguide.com
http://voyageauperou.leblogguide.com
http://voyageauchili.leblogguide.com
http://italiehotels.leblogguide.com