/usr/share/doc/python-gtk2-tutorial/html/examples/fontbutton.py is in python-gtk2-tutorial 2.4-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | #!/usr/bin/env python
import pygtk
pygtk.require('2.0')
import gtk
class FontButtonExample:
def __init__(self):
window = gtk.Window()
window.connect('destroy', lambda w: gtk.main_quit())
vbox = gtk.VBox()
window.add(vbox)
hbox = gtk.HBox()
vbox.pack_start(hbox, False)
label = gtk.Label('Current Font:')
hbox.pack_start(label, False)
fontbutton = gtk.FontButton('Monospace Italic 14')
fontbutton.set_use_font(True)
fontbutton.set_title('Select a font')
fontbutton.connect('font-set', self.font_set_cb)
hbox.pack_start(fontbutton)
self.fontbutton = fontbutton
bbox = gtk.HButtonBox()
vbox.pack_start(bbox, False)
b = gtk.ToggleButton('use_font', False)
b.connect('toggled', self.use_font_cb)
b.set_active(True)
bbox.pack_start(b)
b = gtk.ToggleButton('use_size', False)
b.connect('toggled', self.use_size_cb)
b.set_active(False)
bbox.pack_start(b)
b = gtk.ToggleButton('show_style', False)
b.connect('toggled', self.show_style_cb)
b.set_active(True)
bbox.pack_start(b)
b = gtk.ToggleButton('show_size', False)
b.connect('toggled', self.show_size_cb)
b.set_active(True)
bbox.pack_start(b)
window.show_all()
return
def use_font_cb(self, togglebutton):
self.fontbutton.set_use_font(togglebutton.get_active())
return
def use_size_cb(self, togglebutton):
self.fontbutton.set_use_size(togglebutton.get_active())
return
def show_style_cb(self, togglebutton):
self.fontbutton.set_show_style(togglebutton.get_active())
return
def show_size_cb(self, togglebutton):
self.fontbutton.set_show_size(togglebutton.get_active())
return
def font_set_cb(self, fontbutton):
font = fontbutton.get_font_name()
print 'You have selected the font:', font
return
def main():
gtk.main()
if __name__ == '__main__':
cbe = FontButtonExample()
main()
|