Gtk.FontButton


Gtk.FontButton — A button to launch a font chooser dialog

Object Hierarchy:

    GObject
    ╰── GInitiallyUnowned
        ╰── Gtk.Widget
            ╰── Gtk.Container
                ╰── Gtk.Bin
                    ╰── Gtk.Button
                        ╰── Gtk.FontButton

See also:

Gtk.FontChooserDialog, Gtk.ColorButton.


Functions:

Description:

The Gtk.FontButton is a button which displays the currently selected font an allows to open a font chooser dialog to change the font.

It is suitable widget for selecting a font in a preference dialog.


Function Details:

new()

new () -> Gtk.Widget

Creates a new font picker widget.

  • Returns: a new font picker widget.

  • Since: 2.4


new_with_font()

new_with_font (fontname:str) -> Gtk.Widget

Creates a new font picker widget.

  • Returns: a new font picker widget.

  • Since: 2.4


set_font_name()

set_font_name (self, fontname:str) -> bool

Sets or updates the currently-displayed font in font picker dialog.

  • Returns: True

  • Since: 2.4


get_font_name()

get_font_name (self) -> str

Retrieves the name of the currently selected font. This name includesstyle and size information as well. If you want to render somethingwith the font, use this string with pango_font_description_from_string() .If you’re interested in peeking certain values (family name,style, size, weight) just query these properties from thePangoFontDescription object.

  • Returns: an internal copy of the font name which must not be freed.

  • Since: 2.4


set_show_style()

set_show_style (self, show_style:bool)

If show_style is True, the font style will be displayed along with name of the selected font.

  • Since: 2.4

get_show_style()

get_show_style (self) -> bool

Returns whether the name of the font style will be shown in the label.

  • Returns: whether the font style will be shown in the label.

  • Since: 2.4


set_show_size()

set_show_size (self, show_size:bool)

If show_size is True, the font size will be displayed along with the name of the selected font.

  • Since: 2.4

get_show_size()

get_show_size (self) -> bool

Returns whether the font size will be shown in the label.

  • Returns: whether the font size will be shown in the label.

  • Since: 2.4


set_use_font()

set_use_font (self, use_font:bool)

If use_font is True, the font name will be written using the selected font.

  • Since: 2.4

get_use_font()

get_use_font (self) -> bool

Returns whether the selected font is used in the label.

  • Returns: whether the selected font is used in the label.

  • Since: 2.4


set_use_size()

set_use_size (self, use_size:bool)

If use_size is True, the font name will be written using the selected size.

  • Since: 2.4

get_use_size()

get_use_size (self) -> bool

Returns whether the selected size is used in the label.

  • Returns: whether the selected size is used in the label.

  • Since: 2.4


set_title()

set_title (self, title:str)

Sets the title for the font chooser dialog.

  • Since: 2.4

get_title()

get_title (self) -> str

Retrieves the title of the font chooser dialog.

  • Returns: an internal copy of the title string which must not be freed.

  • Since: 2.4


Example:

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

def font_changed(fontbutton):
    print("Font selected: %s" % fontbutton.get_font_name())

window = Gtk.Window()
window.set_title("FontButton")
window.set_default_size(150, -1)
window.connect("destroy", Gtk.main_quit)

fontbutton = Gtk.FontButton(title="FontButton")
fontbutton.connect("font-set", font_changed)
window.add(fontbutton)

window.show_all()

Gtk.main()

results matching ""

    No results matching ""