[scribus] path question for a script to find itself

Gregory Pittman gpittman at iglou.com
Fri Oct 13 23:03:31 UTC 2017


On 10/13/2017 09:47 AM, ZASKE Martin wrote:
> 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.)

I'm a little fuzzy on what you want to do, but I think you're looking
for functions of the os module, where you would need to

import os

os.chdir('C:\Users\martin\1\comp\Scribus\scripts\mylatesttool\')

So that then you could look for your .ico file in that directory.

Greg




More information about the scribus mailing list