Documentation

askfont

tkfontchooser.askfont(master=None, text='Abcd', title='Font Chooser', **font_args)[source]

Open the font chooser and return a dictionary of the font properties.

General Arguments:

master : Tk or Toplevel instance
master window
text : str
sample text to be displayed in the font chooser
title : str
dialog title

Font arguments:

family : str
font family
size : int
font size
slant : str
“roman” or “italic”
weight : str
“normal” or “bold”
underline : bool
whether the text is underlined
overstrike : bool
whether the text is overstriked

Output:

dictionary is similar to the one returned by the actual method of a tkinter Font object:

{'family': str,
 'size': int,
 'weight': 'bold'/'normal',
 'slant': 'italic'/'roman',
 'underline': bool,
 'overstrike': bool}

FontChooser

FontChooser inherits from all Toplevel methods.

class tkfontchooser.FontChooser(master, font_dict={}, text='Abcd', title='Font Chooser', **kwargs)[source]

Font chooser dialog.

__init__(master, font_dict={}, text='Abcd', title='Font Chooser', **kwargs)[source]

Create a new FontChooser instance.

Arguments:

master : Tk or Toplevel instance
master window
font_dict : dict

dictionnary, like the one returned by the actual method of a Font object:

{'family': str,
 'size': int,
 'weight': 'bold'/'normal',
 'slant': 'italic'/'roman',
 'underline': bool,
 'overstrike': bool}
text : str
text to be displayed in the preview label
title : str
window title
kwargs : dict
additional keyword arguments to be passed to Toplevel.__init__
get_res()[source]

Return chosen font.

ok()[source]

Validate choice.