RSS/Atom feed Twitter
Site is read-only, email is disabled

Finding the gimp icon path in Python....

This discussion is connected to the gimp-developer-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

2 of 2 messages available
Toggle history

Please log in to manage your subscriptions.

Finding the gimp icon path in Python.... Ragnar Brynjúlfsson 14 Aug 18:56
  Finding the gimp icon path in Python.... Joao S. O. Bueno 15 Aug 15:45
Ragnar Brynjúlfsson
2012-08-14 18:56:32 UTC (over 12 years ago)

Finding the gimp icon path in Python....

How can I reliably find the path to where the Gimp icons are across all platforms?

I'm basically doing:

self.set_icon_from_file("/usr/share/icons/hicolor/scalable/apps/gimp.svg")

in a PyGtk plug-in, which will obviously break on Windows, OSX and even on some other Linux distros.

Joao S. O. Bueno
2012-08-15 15:45:26 UTC (over 12 years ago)

Finding the gimp icon path in Python....

On 14 August 2012 15:56, Ragnar Brynjúlfsson wrote:

How can I reliably find the path to where the Gimp icons are across all platforms?

I'm basically doing:

self.set_icon_from_file("/usr/share/icons/hicolor/scalable/apps/gimp.svg")

in a PyGtk plug-in, which will obviously break on Windows, OSX and even on some other Linux distros.

Again, there is no API for that - The wya to proceed is to check the __file__ attribute of Python's "gimp" module, and
infer the icons directory from that.

For example, here I have, on python-fu's console:

import gimp
gimp.__file__

'/usr/lib64/gimp/2.0/python/gimp.so'

So, if that string starts with either "/usr/lib" or "/usr/lib64", "usr/share" is the way to go.
Possibly this could work for any gimp build which dos not specialize the application prefixes:

icon_path = gimp.__file__.split("/lib")[0] + "/share/icons/hicolor/scalable/apps/gimp.svg"

_______________________________________________ gimp-developer-list mailing list
gimp-developer-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gimp-developer-list