[cairo] Alpha channel [pycairo]
Manuel
origin.of at gmail.com
Sat Mar 10 12:56:51 PST 2007
hi all, I've this "program" :
# main.py
# -*- coding: UTF-8 -*-
import pygtk
pygtk.require('2.0')
import gtk, gobject, cairo
# Create a GTK+ widget on which we will draw using Cairo
class Screen(gtk.DrawingArea):
# Draw in response to an expose-event
__gsignals__ = { "expose-event": "override" }
# Handle the expose-event by drawing
def do_expose_event(self, event):
cr = self.window.cairo_create()
self.draw(cr, *self.window.get_size())
def draw(self, cr, width, height):
cr.set_tolerance(0.1)
cr.set_source_rgba(0.0, 0.0, 0.0, 0.5)
cr.set_operator(cairo.OPERATOR_SOURCE)
cr.paint()
# GTK mumbo-jumbo to show the widget in a window and quit when it's closed
def run(Widget):
window = gtk.Window(type=gtk.WINDOW_TOPLEVEL)
window.set_decorated(False)
window.set_resizable(False)
window.connect("delete-event", gtk.main_quit)
widget = Widget()
screen = widget.get_screen()
color = screen.get_rgba_colormap()
widget.set_colormap(color)
widget.set_app_paintable(True)
widget.set_size_request(500, 500)
widget.show()
window.add(widget)
window.present()
gtk.main()
if __name__ == "__main__":
run(Screen)
try execute it, the alpha channel doesn't work...
The windows isn't semi-transparent...
cr.set_source_rgba(0.0, 0.0, 0.0, 0.5) doesn't work ??
More information about the cairo
mailing list