Environment: Python3
Libraries:
from gi.repository import Gtk, Gdk
import cairo
I want to create a 'pixbuf from file' but the method does not longer exist in Gdk3.
pb = Gdk.pixbuf_new_from_file('sunshine.png')
Gdk.cairo_set_source_pixbuf(cr, pb, 0, 0)
Result in: AttributeError: 'gi.repository.Gdk' object has no attribute 'pixbuf_new_from_file'
Does anybody know how to do this with Gdk3? Seems that Gdk3 only support these methods:
gdk_pixbuf_get_from_window
gdk_pixbuf_get_from_surface
Update
Found it out myself:
image = Gtk.Image()
image.set_from_file('sunshine.png')
pixbuf = image.get_pixbuf()
Gdk.cairo_set_source_pixbuf(cr, pixbuf, 10, 10)