[scribus] path question for a script to find itself
ZASKE Martin
zm at revue-gugu.org
Tue Oct 17 17:34:40 UTC 2017
Dear Greg and Bert and list,
thank you for your first attempts.
Since you asked; what do I want to do:
I want to show images in the window (TK) which comes up when running my
script from Scribus.
But - since I will distribute my script to my team and to my wife - I do
NOT know where they will place it on other computers.
All I know is that I am providing one folder, holding both myscript and
some other resources and images and I will ask them to keep the folder
together. This is meant for both Windows and OpenSuse Scribus installations.
Now I need the script to find out its own location dynamically (if that
is the correct term) so that it can use those resources, for example
show the images.
I need a relative path, rather than an absolute path. When I try
applying the "normal" Python stuff, it is giving me the "working folder"
of Scribus, not the location where my script is stored. I believe this
happens, because Scribus is calling the script.
I tried to look what __file__ would give, but I get this error:
"NameError: name '__file__' is not defined", so even trying to catch it
with "if not" did not help.
More indirect approach: Since my script is being called from Scribus,
maybe it does indeed not know about its own location. But Scribus does
know! It even keeps tabs, for providing this very helpful menu entry
"recent scripts...".
So maybe I should not ask my script about itself, maybe I should ask
Scribus. In the API, Scribus is providing a lot of handles about the
open document and about selected objects. Where might I find a handle on
the presently-running-user-script?
Hope it is clearer now, thanks again,
Martin
> 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
>
>
> ___
> Scribus Mailing List: scribus at lists.scribus.net
> Edit your options or unsubscribe:
> http://lists.scribus.net/mailman/listinfo/scribus
> See also:
> http://wiki.scribus.net
> http://forums.scribus.net
>
> __________ Hinweis von ESET NOD32 Antivirus, Version der Erkennungsroutine 16241 (20171014) __________
>
> E-Mail wurde geprüft mit ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
>
>
--
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