If you are writing a Tkinter application and you want to let the user change one or more fonts, you can include a widget in your application. Simply create it with this constructor:
w= (master, font=f, listCount=L, observer=F)
w
The constructor returns a new, ungridded widget.
master
The parent Frame widget in which this widget will be mastered.
font=f
If you don't like the font used inside this widget,
supply this optional keyword argument with f set to your preferred font as a tkFont.Font object.
listCount=L
By default, the number of families displayed in the
family is
15. If you want a different number,
pass that number as an integer to this optional keyword
argument. This pretty
much determines the overall height of the widget
on the screen.
L
observer=F
An “observer” function to be called whenever any of the currently displayed font options change. The calling sequence is:
F(newFont)
where is a Python newFonttkFont.Font
object representing the currently selected font.
Here are the public attributes and methods of a object:
.scrollList
A widget containing the family names and associated scrollbar.
.get()
Returns the currently selected font as a Python tkFont.Font object. If no font has ever
been set, returns None.
.getName()
Returns a string describing all the current font options.
This string starts with the family and size, followed
optionally by the strings "bold" and/or
"italic". Example: "luxi mono 14
bold italic". If no font has ever
been set, returns None.
.addObserver ( f )
Adds an observer function that will be called
whenever any of the font options change. The calling
sequence of the f function is as described under the fobserver=
argument to the constructor.
f