FontChooserDialog

The FontChooserDialog provides a FontChooserWidget within a dialog window.

The dialog-variant of the FontChooser family allows for choosing fonts, styling and sizes.

Constructor

The FontChooserDialog can be constructed using the following:

fontchooserdialog = Gtk.FontChooserDialog(title, parent)

A title should be specified via a string of text which identifies the function of the FontChooserDialog. The parent parameter can be the name of a Window or Dialog which owns the FontChooserDialog.

Methods

Once the FontChooserDialog has been constructed use:

fontchooserdialog.run()
fontchooserdialog.destroy()

Note

If you application only uses a dialog window, the Gtk.main() call is not required. This is invoked automatically when calling fontchooserdialog.run().

The title of the dialog which is displayed can be set with:

fontchooserdialog.set_title(title)

Example

Below is an example of a FontChooserDialog:

#!/usr/bin/env python3

from gi.repository import Gtk

fontchooserdialog = Gtk.FontChooserDialog()
fontchooserdialog.set_title("FontChooserDialog")

response = fontchooserdialog.run()

if response == Gtk.ResponseType.OK:
    print("Font selected: %s" % fontchooserdialog.get_font())

fontchooserdialog.destroy()

Download: FontChooserDialog