FAQ Index - Search - Recent Changes - Everything - Add entry

<< Previous Entry | FAQ Entry 4.17 | Next Entry >>

4.17. Why does FontSelection's set_font_name return False?

It needs to be added to a window before the font lists are populated.

  >>> w = gtk.Window()
  >>> f = gtk.FontSelection()
  >>> f.get_font_name()
  'Sans 10'
  >>> f.set_font_name('Sans 12')
  False
  >>> w.add(f)
  >>> f.set_font_name('Sans 12')
  True
Once added to the window, the result will indeed be True.

PyGTK FAQ Wizard | PyGTK Homepage | Feedback to faq at pygtk.org