Reputation: 12459
In gtk.gdk.pixbuf_new_from_file(image)
, if "image" is not an absolute path, I get:
glib.GError: Failed to open file 'image.png': No such file or directory
That's unless I'm in the directory where the image lives.
note1: I'm running Debian Squeeze, which uses Python 2.6 by default.
note2: The image and the script live in one directory.
Upvotes: 0
Views: 1071
Reputation: 5021
This is not specific to pixbuf_new_from_file
, relative paths are always resolved relative to the current directory, which initially is the directory the script is started from.
You can get the directory the script is actually in with os.path.dirname(__file__)
. Then you can either make it your script's current directory with os.chdir
, or you can use os.path.join
to combine it with image.png
.
Upvotes: 1