Gtk.FontChooserWidget


Gtk.FontChooserWidget — A widget for selecting fonts

Object Hierarchy:

    GObject
    ╰── GInitiallyUnowned
        ╰── Gtk.Widget
            ╰── Gtk.Container
                ╰── Gtk.Box
                    ╰── Gtk.FontChooserWidget

See also:

Gtk.FontChooserDialog


Functions:

  • new () -> Gtk.Widget

Description:

The Gtk.FontChooserWidget widget lists the available fonts, styles and sizes, allowing the user to select a font. It is used in the Gtk.FontChooserDialog widget to provide a dialog box for selecting fonts.

To set the font which is initially selected, use Gtk.FontChooser::set_font() or Gtk.FontChooser::set_font_desc().

To get the selected font use Gtk.FontChooser::get_font() or Gtk.FontChooser::get_font_desc().

To change the text which is shown in the preview area, use Gtk.FontChooser::set_preview_text().


Function Details:

new()

new () -> Gtk.Widget

Creates a new Gtk.FontChooserWidget.

  • Returns: a new Gtk.FontChooserWidget

  • Since: 3.2


Example:

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk

def font_chooser(fontchooserwidget, font):
    print("Font selected: %s" % font)

window = Gtk.Window()
window.set_title("FontChooserWidget")
window.connect("destroy", Gtk.main_quit)

fontchooserwidget = Gtk.FontChooserWidget()
fontchooserwidget.connect("font-activated", font_chooser)
window.add(fontchooserwidget)

window.show_all()

Gtk.main()

results matching ""

    No results matching ""