Support Christine Media Player


Support This Project

Christine

FeedBurner

 Subscribe to the General Feed

Add to Google Reader or Homepage

Categories

Tiras


Tira Ecol
Tira Ecol


Tira LinuxHispano.net
La Legión del Espacio

Poll

Recent Comments

Saturday 21 July 2007 10:52am
Categories
general
Software_Development
stuff
Python
gtk
FLOSS

Para dibujar usando cairo por lo general creas un objeto heredando propiedades de gtk.DrawingArea. y obviamente, tenemos un metodo para el redibujado. Dentro de ese metodo metemos esto:

def setPixbuf(self,pixbuf):
        if type(pixbuf) != gtk.gdk.Pixbuf:
                raise TypeError("Pixbuf debe ser %s recibido %s"%(gtk.gdk.Pixbuf, type(pixbuf)))
        self.__Pixbuf = pixbuf
        self.emit("expose-event",gtk.gdk.Event(gtk.gdk.EXPOSE))

def exposeEvent(self, widget,event):
        x,y,w,h = self.allocation
        try:
                context =  self.window.cairo_create()
        except AttributeError:
                return True

        if self.__Pixbuf != None:
                scaledPixbuf = self.__Pixbuf.scale_simple(ancho,
                                alto,
                                gtk.gdk.INTERP_BILINEAR)
                ct = gtk.gdk.CairoContext(context)
                ct.set_source_pixbuf(scaledPixbuf,BORDER_WIDTH,BORDER_WIDTH)
                context.paint()
                context.stroke()

 

Y listo face-smile.png

Trackback URI: http://www.islascruz.org/html/index.php?Blog/Trackback/id/430

Leave a Comment









Comment XML feeds: RSS | Atom
Online Visitors:8 Today Visitors:79 Total Visitors:533622

Technorati