Wednesday: Python3
Libraries:
from gi.repository import Gtk, Gdk import cairo
I want to create "pixbuf from a file", but this method no longer exists in Gdk3.
pb = Gdk.pixbuf_new_from_file('sunshine.png') Gdk.cairo_set_source_pixbuf(cr, pb, 0, 0)
Result in: AttributeError: object 'gi.repository.Gdk' does not have attribute 'pixbuf_new_from_file'
Does anyone know how to do this with Gdk3? Gdk3 seems to support only these methods:
gdk_pixbuf_get_from_window gdk_pixbuf_get_from_surface
Update
Found myself:
image = Gtk.Image() image.set_from_file('sunshine.png') pixbuf = image.get_pixbuf() Gdk.cairo_set_source_pixbuf(cr, pixbuf, 10, 10)
source share