gtk.FontSelection
Prev | The gtk Class Reference | Next

## gtk.FontSelection

gtk.FontSelection — a widget for selecting fonts.

## Synopsis

    class gtk.FontSelection(gtk.VBox):
        gtk.FontSelection()
        def get_font_name()
        def set_font_name(fontname)
        def get_preview_text()
        def set_preview_text(text)

## Ancestry

    +-- gobject.GObject
      +-- gtk.Object
        +-- gtk.Widget
          +-- gtk.Container
            +-- gtk.Box
              +-- gtk.VBox
                +-- gtk.FontSelection

## gtk.FontSelection Properties

gtk.Object Properties

gtk.Widget Properties

gtk.Container Properties

gtk.Box Properties

"font" | Read | The gtk.gdk.Font that is currently selected. This property is deprecated.
"font-name" | Read/Write | The string that names the font
"preview-text" | Read/Write | The text to display in order to demonstrate the selected font.

## gtk.FontSelection Style Properties

gtk.Widget Style Properties

## gtk.FontSelection Child Properties

gtk.Box Child Properties

## gtk.FontSelection Signal Prototypes

gobject.GObject Signal Prototypes

gtk.Object Signal Prototypes

gtk.Widget Signal Prototypes

gtk.Container Signal Prototypes

## Description

The `gtk.FontSelection` widget lists the available fonts, styles and sizes, allowing the user to select a font. It is used in the `gtk.FontSelectionDialog` widget to provide a dialog box for selecting fonts. The `set_font_name`() method sets the initial font selection. The current font selection is retrieved using the `get_font_name`() method.

The fontselection has a preview area that contains a `gtk.Entry` that displays text using the currently selected font. The preview text can be retrieved with the `get_preview_text`() method and set with the `set_preview_text`() method.

Filters can be used to limit the font selections. There are 2 filters in the `gtk.FontSelection` - a base filter and a user filter. The base filter cannot be changed by the user, so this can be used when the user must choose from the restricted set of fonts (e.g. for a terminal-type application you may want to force the user to select a fixed-width font). The user filter can be changed or reset by the user, by using the Reset Filter button or changing the options on the Filter page of the widget.

## Constructor

        gtk.FontSelection()

Returns : | a new fontselection widget

Creates a new `gtk.FontSelection` widget.

## Methods

### gtk.FontSelection.get_font_name

        def get_font_name()

Returns : | a string containing the selected font name

The `get_font_name`() method returns the name of the currently selected font.

### gtk.FontSelection.set_font_name

        def set_font_name(fontname)

`fontname` : | a string containing the name of a font
Returns : | `True` if the font could be set

The `set_font_name`() method sets the currently selected font in the fontselection using the value of `fontname`. The method returns `True` if the font is found and can be selected in the fontselection.

### gtk.FontSelection.get_preview_text

        def get_preview_text()

Returns : | a string containing the preview text

The `get_preview_text`() method returns a string that contains the text displayed in the preview area entry.

### gtk.FontSelection.set_preview_text

        def set_preview_text(text)

`text` : | the new preview text string

The `set_preview_text`() method sets the text to be displayed in the preview area entry using the string in `text`.

Prev | Up | Next
gtk.FontButton | Home | gtk.FontSelectionDialog