3

I'm trying to use GdkPixbuf.Pixbuf.new_from_file() to create a new pixbuf from file, but Python interpreter gives me the following error:

GLib.Error: g-invoke-error-quark: Could not locate gdk_pixbuf_new_from_file: 'gdk_pixbuf_new_from_file'

The strange thing is new_from_file_at_size() doesn't give any error and works as expected.

I'm working under Windows 10, Python 3.4 and I have installed PyGObject from here.

Cimbali
  • 11,012
  • 1
  • 39
  • 68
pozzugno
  • 750
  • 6
  • 19
  • I don't see that in the docs. From the docs, it looks to me like you're supposed to use [this](https://developer.gnome.org/gdk3/stable/gdk3-Pixbufs.html#gdk-pixbuf-get-from-surface) on a Cairo surface, or even better just use Cairo entirely. – oldtechaa Dec 13 '16 at 19:21
  • What can't you see in the docs? new_from_file() function? It is described [here](https://developer.gnome.org/gdk-pixbuf/2.36/gdk-pixbuf-File-Loading.html#gdk-pixbuf-new-from-file). – pozzugno Dec 13 '16 at 22:09
  • It is described [here](https://lazka.github.io/pgi-docs/#GdkPixbuf-2.0/classes/Pixbuf.html#GdkPixbuf.Pixbuf.new_from_file) too. – pozzugno Dec 13 '16 at 22:26
  • Didn't know gdk-pixbuf had separate docs and versioning. I don't use GDK for drawing in favor of Cairo, so I'm not as knowledgeable about it. Any reason you aren't using Cairo? – oldtechaa Dec 14 '16 at 14:25
  • I don't know. I'm new with Gtk and now I need to add some images to a TreeView widget. Many examples explain to use a CellRendererPixbuf to show an image in a cell of a TreeView. So I'm trying to use a pixbuf. Sincerely I don't know what exactly is Cairo, I only header about it when I read some docs about Gtk. – pozzugno Dec 14 '16 at 22:34
  • Cairo is an independent drawing API that GTK+ chose for drawing widgets and recommends to users. You can find more [here](https://cairographics.org). Like I said, I don't use GDK so I can't say if Cairo's better for your purposes, but if you look at Cairo and see which seems more suitable, you can make the call. – oldtechaa Dec 15 '16 at 02:24

1 Answers1

1

It appears there is a Gdk-Pixbuf package that you have forgotten to tick when installing PyGObjectWin32.

If there is an installation manager in the install folder, use it to add the missing package. Otherwise you'll just have to reinstall, making sure that the box is ticked.

Cimbali
  • 11,012
  • 1
  • 39
  • 68