[scribus] path question for a script to find itself

ZASKE Martin zm at revue-gugu.org
Fri Oct 13 13:47:13 UTC 2017


Dear list,

holiday coming up and trying to hack some new stuff.



I am today learning how to handle certain paths, not least the path
where my script is located (because I want to load its folder with some
icons - and then access them, independent of where a user is keeping the
script).

Normally it would work with something like this:

myicon = os.path.join(os.path.abspath('.'),'mybeautifulicon.ico')


But since my script must be called from Scribus, the dot-reference is
giving me some "random" folder, related to Scribus (not even related to
the calling scribus.document), for example:

C:\Program Files\Scribus 1.5.4.svn\translations\


Have the veterans please got an idea for me, how to access the location
of my script.

If you prefer specific examples, you can use this:

"C:\Users\martin\1\comp\Scribus\scripts\mylatesttool\tool_08.py"



With my above line of code, I had hoped to get from the abspath:

C:\Users\martin\1\comp\Scribus\scripts\mylatesttool\

and then of course from the join:

C:\Users\martin\1\comp\Scribus\scripts\mylatesttool\mybeautifulicon.ico

(The joining works fine, just the reference is off.)




Context is Tkinter. If there is an even more direct or more elegant way
of referencing to the script itself (when called from Scribus), just
laugh at my idea and write a better one.



Thanks,

Martin


-- 
ZASKE Martin
responsable GʊGʊ
BP 50 - Bassila - Bénin
tel GʊGʊ 66.66.11.11
tel pers 97.44.62.95



More information about the scribus mailing list