Font Dialog

Find Dialog Sample

Creating the Dialog

Create a Font Dialog by calling dialog.fontDialog with one required argument and one optional argument as shown in the following table:

Argument
Data Type/Notes
self
the window (background) that is the parent for the dialog
OPTIONAL aFont
Python dictionary containing a complete font description to be used as the default starting point for the dialog. See description of return value of "font" in table below for details.


Example:

Above dialog was created with this line of code:

result = dialog.fontDialog(self)

Interacting With the Dialog

The fontDialog component returns a wxPython DialogResults object which contains 3 attributes, as shown in the following table

Name of value
Description
accepted
True = user clicked OK
False = user clicked Cancel
color
Tuple of three elements containing the red, blue, and green values representing the color (i.e., RGB format)
font
Python dictionary object with keys style, faceName, family, and size. All elements of dictionary are strings except for size, which is an integer.

Example:

The sample dialog shown at the top of this page returns the following results:

accepted: True
color: (0, 0, 0)
font: {'style': 'bold', 'faceName': 'Arial', 'family': 'sansSerif', 'size': 12}