Direct script failed but successed in console!

Previous topic - Next topic



I have a strange behavior for my script


If you test it (there is also a test Scribus doc in my GitHub repository), it is OK in the console (load and run in console), but when you try directly through the script menu, I got

Traceback (most recent call last):
  File "<string>", line 11, in <module>
  File "<string>", line 768, in <module>
  File "<string>", line 754, in main_wrapper
  File "<string>", line 668, in main
  File "<string>", line 465, in welcome_banner
NameError: name 'ICON_INFORMATION' is not defined

The script seems not to recognize the Scribus environment, at least, this is the way I interpret the error message, because this is the first step in the script where you call a pop-up message (so a Qt widget...).

It is quiet difficult to debug without console :)

Is there a way to debug this problem? Or, better, do you a track for helping me?





Thanks, I read a lot before to understand :)

All is good now  ;D

I just want to understand why my script run before only in console. when you are in console, the dialog environment, like icon name, are already load?

Thanks in any cases !


it's because in the console the functions and constants from the scribus namespace are loaded into the global namespace.

you could do that in your script, too... but, personally, i would advise you not to do it and put scribus. in front of each call of the scribus API: a bit more verbose, but IMO much easier to understand what is going on.

btw, since you're on the line: it would be a good idea to remove the

#!/usr/bin/env python3

at the beginning of your script.

this is only useful if you start the script from a terminal, but that is not possible since -- as you correctly let your script say a few lines later -- the script must be started from inside scribus.


OK, thanks for all.

I removed the first line too.