#!/usr/bin/env python3# Created by xiaosanyu at 16/6/27# section 008
TITLE = "FontButton"
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.
"""import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk
classFontButtonWindow(Gtk.Window):def__init__(self):
Gtk.Window.__init__(self, title="FontButton Demo")
self.set_border_width(10)
self.set_default_size(200, 50)
box = Gtk.Box()
fbtn = Gtk.FontButton(use_font=True, use_size=True)
fbtn.connect("font-set", self.font_selected)
box.add(fbtn)
self.add(box)
@staticmethoddeffont_selected(btn):
print(btn.get_font_name())
defmain():
win = FontButtonWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()
if __name__ == "__main__":
main()