#coding:utf-8
import gtk
import cairo
class Lrc(object):
def __init__(self):
self.win = gtk.Window(gtk.WINDOW_TOPLEVEL);
self.alpha = 0.5
self.win.add_events(gtk.gdk.ALL_EVENTS_MASK);
self.win.set_colormap(gtk.gdk.Screen().get_rgba_colormap())
self.win.connect("expose-event", self.expose_test_window);
# self.win.connect("realize", self.realize_test_window)
self.win.show_all()
def expose_test_window(self, widget, event):
# Init.
cr = widget.window.cairo_create()
rect = widget.allocation
# Clear color to transparent window.
cr.set_source_rgba(0.0, 0.0, 0.0, self.alpha)
cr.set_operator(cairo.OPERATOR_SOURCE)
cr.paint()
return True
def realize_test_window(self, widget):
self.win.window.input_shape_combine_region(gtk.gdk.Region(), 0, 0)
# pixmap = gtk.gdk.Pixmap(widget.window,
# widget.allocation.width,
# widget.allocation.height, -1)
# cr = pixmap.cairo_create()
# cr.set_source_pixmap(widget.window,
# widget.allocation.x,
# widget.allocation.y)
# cr.paint()
# cr.set_source_rgba(0.0, 0.0, 0.0, 0.5)
# cr.paint()
# self.win.window.set_back_pixmap(pixmap, False)
self.win.window.set_back_pixmap(None, False)
Lrc()
gtk.main()
import gtk
import cairo
class Lrc(object):
def __init__(self):
self.win = gtk.Window(gtk.WINDOW_TOPLEVEL);
self.alpha = 0.5
self.win.add_events(gtk.gdk.ALL_EVENTS_MASK);
self.win.set_colormap(gtk.gdk.Screen().get_rgba_colormap())
self.win.connect("expose-event", self.expose_test_window);
# self.win.connect("realize", self.realize_test_window)
self.win.show_all()
def expose_test_window(self, widget, event):
# Init.
cr = widget.window.cairo_create()
rect = widget.allocation
# Clear color to transparent window.
cr.set_source_rgba(0.0, 0.0, 0.0, self.alpha)
cr.set_operator(cairo.OPERATOR_SOURCE)
cr.paint()
return True
def realize_test_window(self, widget):
self.win.window.input_shape_combine_region(gtk.gdk.Region(), 0, 0)
# pixmap = gtk.gdk.Pixmap(widget.window,
# widget.allocation.width,
# widget.allocation.height, -1)
# cr = pixmap.cairo_create()
# cr.set_source_pixmap(widget.window,
# widget.allocation.x,
# widget.allocation.y)
# cr.paint()
# cr.set_source_rgba(0.0, 0.0, 0.0, 0.5)
# cr.paint()
# self.win.window.set_back_pixmap(pixmap, False)
self.win.window.set_back_pixmap(None, False)
Lrc()
gtk.main()