<div dir="ltr">Yes, great - it works!<div>This saves my a lot of time :)</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jun 5, 2015 at 3:52 AM, Gregory Pittman <span dir="ltr"><<a href="mailto:gpittman@iglou.com" target="_blank">gpittman@iglou.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I somehow lost this email from my client, but here it is copied from the<br>
Archives:<br>
*************************<br>
I am trying to run the following (very simple) script:<br>
<br>
#!/usr/bin/env python<br>
# -*- coding: utf-8 -*-<br>
<br>
import sys<br>
try:<br>
import scribus<br>
<br>
except ImportError:<br>
print "This script only works from within Scribus"<br>
sys.exit(1)<br>
<br>
n = scribus.selectionCount()<br>
<br>
for count in range(0,n):<br>
textbox = scribus.getSelectedObject(count)<br>
scribus.messageBox('Error:', textbox);<br>
scribus.setFont('Arial Regular', textbox)<br>
scribus.setTextAlignment(scribus.ALIGN_CENTERED, textbox)<br>
scribus.setTextColor("White", textbox)<br>
scribus.setFillColor("Red", textbox)<br>
<br>
<br>
However it fails after one iteration. The error message is:<br>
<br>
Traceback (most recent call last):<br>
File "<string>", line 8, in <module><br>
File "/home/.../SetTableHeading.py", line 17, in <module><br>
scribus.setFont('Arial Regular', textbox)<br>
NoValidObjectError: Cannot use empty string for object name when there is<br>
no selection<br>
<br>
If I remove the function calls scribus.setFont() and<br>
scribus.setTextAlignment(), the script runs fine, but I dont know why...<br>
<br>
I am running Scribus 1.4.3 and python 2.7.6 under Ubuntu 14.04.2 LTS.<br>
<br>
I am not able to find any solution to this - any suggestions?<br>
<br>
regards,<br>
Anders<br>
<br>
*****************************<br>
<br>
I'm not quite sure why this doesn't work, but I am able to accomplish<br>
what you're looking for (I think) with a modified syntax. Basically,<br>
instead of relying on the count of the selection, I create a list of<br>
frame names, then feed that list into your text manipulations...<br>
<br>
*************<br>
#!/usr/bin/env python<br>
# -*- coding: utf-8 -*-<br>
<br>
import sys<br>
try:<br>
import scribus<br>
<br>
except ImportError:<br>
print "This script only works from within Scribus"<br>
sys.exit(1)<br>
<br>
n = scribus.selectionCount()<br>
boxes = []<br>
<br>
for x in range(n):<br>
frame = scribus.getSelectedObject(x)<br>
boxes.append(frame)<br>
<br>
for textbox in boxes:<br>
scribus.messageBox('Error:', textbox);<br>
scribus.setFont('Arial Regular', textbox)<br>
scribus.setTextAlignment(scribus.ALIGN_CENTERED, textbox)<br>
scribus.setTextColor("White", textbox)<br>
scribus.setFillColor("Red", textbox)<br>
<br>
*************<br>
<br>
Greg<br>
<br>
___<br>
Scribus Mailing List: <a href="mailto:scribus@lists.scribus.net">scribus@lists.scribus.net</a><br>
Edit your options or unsubscribe:<br>
<a href="http://lists.scribus.net/mailman/listinfo/scribus" target="_blank">http://lists.scribus.net/mailman/listinfo/scribus</a><br>
See also:<br>
<a href="http://wiki.scribus.net" target="_blank">http://wiki.scribus.net</a><br>
<a href="http://forums.scribus.net" target="_blank">http://forums.scribus.net</a><br>
</blockquote></div><br></div>