Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python-fu path of the plug-ins folder
#1
Hello,

I'm using Python-fu to write a plugin. Is there any way to get the path of the plug-ins folder?
Reply
#2
There isn't one single folder, there are "folders", so nothing says that the folder you are looking at is the right one (I use three additional folders besides the standard two, and furthermore they mostly contain soft links to script elsewhere.

If you want to know where your plugin is, use os.path.abspath(sys.argv[0]) (this is the full path to your plugin file..).

Code:
#!/usr/bin/env python
import os,sys
from gimpfu import *

def whoIam(case=None):
    me=sys.argv[0]
    case="Execution" if case is None else case
    print "----\n%s:\nsys.argv[0]=%s\nAbsolute=%s\nReal=%s" % (case,me,os.path.abspath(me),os.path.realpath(me))

whoIam(case='Initialization')

register(
    "whoiam","Who I am","Who I am", "", "", "", "WhoIAm","",[],[],whoIam,menu="<Image>/Test/"
)
main()
The code above will show you that your plugin code is fully executed everytime (you get the "Iniialization" output, besides the one called as the actual plugin function).
Reply
#3
If you want to get the list of folders that are set in preferences:
Code:
pdb.gimp_gimprc_query("plug-in-path")
Reply
#4
Thank you Kevin and Ofnuts for you replies. Very helpful! Smile
Reply


Forum Jump: