[scribus] Python scripter - scribus.setFont() and scribus.setTextAlignment() ?

Anders Jensen jensen.anders.87 at gmail.com
Sun May 31 18:10:00 UTC 2015


Hi,

I am trying to run the following (very simple) script:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
try:
   import scribus

except ImportError:
   print "This script only works from within Scribus"
   sys.exit(1)

n = scribus.selectionCount()

for count in range(0,n):
    textbox = scribus.getSelectedObject(count)
    scribus.messageBox('Error:', textbox);
    scribus.setFont('Arial Regular', textbox)
    scribus.setTextAlignment(scribus.ALIGN_CENTERED, textbox)
    scribus.setTextColor("White", textbox)
    scribus.setFillColor("Red", textbox)


However it fails after one iteration. The error message is:

Traceback (most recent call last):
  File "<string>", line 8, in <module>
  File "/home/.../SetTableHeading.py", line 17, in <module>
    scribus.setFont('Arial Regular', textbox)
NoValidObjectError: Cannot use empty string for object name when there is
no selection

If I remove the function calls scribus.setFont() and
scribus.setTextAlignment(), the script runs fine, but I dont know why...

I am running Scribus 1.4.3 and python 2.7.6 under Ubuntu 14.04.2 LTS.

I am not able to find any solution to this - any suggestions?

regards,
Anders
-------------- neste del --------------
Et HTML-vedlegg ble skilt ut...
URL: <http://lists.scribus.net/pipermail/scribus/attachments/20150531/b13bfafd/attachment.html>


More information about the scribus mailing list