/usr/share/doc/python-gtk2-tutorial/html/examples/colorbutton.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 | #!/usr/bin/env python
import pygtk
pygtk.require('2.0')
import gtk
class ColorButtonExample:
def __init__(self):
window = gtk.Window()
window.connect('destroy', lambda w: gtk.main_quit())
hbox = gtk.HBox()
window.add(hbox)
label = gtk.Label('Foreground Color:')
hbox.pack_start(label, False)
colorbutton = gtk.ColorButton(gtk.gdk.color_parse('red'))
colorbutton.set_use_alpha(True)
colorbutton.set_title('Select a Color')
colorbutton.set_alpha(32767)
colorbutton.connect('color-set', self.color_set_cb)
hbox.pack_start(colorbutton)
window.show_all()
return
def color_set_cb(self, colorbutton):
color = colorbutton.get_color()
alpha = colorbutton.get_alpha()
print 'You have selected the color:', \
color.red, color.green, color.blue, 'with alpha:', alpha
return
def main():
gtk.main()
if __name__ == '__main__':
cbe = ColorButtonExample()
main()
|