PyGTK Font Selection Dialog - PyGTK

What is PyGTK Font Selection Dialog?

The gtk.FontSelection widget lets users to choose and relate the font of a particular name, size and style. The dialog has a preview box containing some text which will be showed in selected font account, and two buttons CANCEL and OK.

PyGTK API covers a Pango module which describes classes and functionality essential to render high quality internationalized text. Font and text handling in gtk is supported by Pango. The pango.Font object signifies a font in a system independent way. The pango.FontDescription object contains the characteristics of a font.

gtk.FontSelectionDialog returns a pango.Font object. In order to apply the selected font, fontmetrics is fetched by obtaining the pango.FontDescription object from it.

The resulting is a constructor of the FontSelectionDialog class –

The resulting are some commonly used methods of this class −

  • get_font_name() − This returns a string containing the currently selected font name or None if no font name is selected.
  • set_font_name() − This sets the current font
  • set_preview_text() − This sets the text in the preview area entry

The selected font is applied to the text in a widget using the modify_font() method.

When FontSelectionDialog menu item is activated, the resulting callback function is invoked –

The selected font is applied to the text of label placed on the toplevel window.

select_font

The resultingis the output –

font_dialog_boxes

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

PyGTK Topics