[pygtk] cairo + transparent png + XShape
Pietro Battiston
toobaz at email.it
Sat Jan 3 19:48:39 WST 2009
Il giorno mer, 31/12/2008 alle 01.22 +0100, Sebastian Bartos ha scritto:
> Hello there,
>
> I'm working on a little app here that uses cairo and a transparent png
> for nifty window design (kind of like widgets/screenlets, no border,
> transparency, etc.)
>
> Now I try to figure out how to tell the XShape extension to take the
> fully transparent parts of the window and cut them away (really
> irregular borders).
>
> Any ideas?
>
> Thanks
> Seth Kriticos
I once tried it, please look if this does what you want (and eventually
do it in some less chaotic way! It was really just a proof of concept):
-----------------------------------------------------------------------
import gtk, gobject
N,M=200,200
drag_icon_xpm = [
str(N)+" "+str(M)+" 1 1",
" c None"]+[' '*N]*M
w = gtk.Window()
def apply_mask():
p = gtk.gdk.pixmap_create_from_xpm_d(w.window , None,
drag_icon_xpm)[1]
r=p.cairo_create()
r.arc(N/2, M/2, min(N,M)/2, .0001, 0)
r.fill()
w.shape_combine_mask(p, 0, 0)
w.set_decorated(False)
return
b=gtk.Button("Click me,\n stupid")
w.add(b)
b.connect('released', gtk.main_quit)
w.set_size_request(200,200)
w.show_all()
gobject.timeout_add(1, apply_mask)
gtk.main()
More information about the pygtk
mailing list