I figured this out, but I am posting this here in case anyone else runs across it.
I has a comment in one of my scripts in which I had accidentally used a single )
. Running that script from the editor was fine, but when I put the script in a button I got the following error message:
I suspect that, despite the fact that it is inside a comment line, that the )
is being interpreted as the end of the script
i.e. normally for a toolbar button the arrangement is this:
NoEcho _-RunPythonScript (
<script here>
)
The last )
completes the encapsulation of the script. As soon as I removed the )
from the comment, the error disappeared. If I added an open parentheses in front ()
, it also ran OK.
Anyway, I don’t know if this is expected, but in case anyone wants to try, here is a simple test script:
mystr="This is a test"
if mystr:
#I accidentally have only a close parentheses ) in my comment
print(mystr)
If you run that from a button, it will error out.