[scribus] Python scripter - scribus.setFont() and scribus.setTextAlignment() ? -- Solution
William Bader
williambader at hotmail.com
Fri Jun 5 02:38:12 UTC 2015
> Date: Thu, 4 Jun 2015 21:52:32 -0400
> From: gpittman at iglou.com
> To: scribus at lists.scribus.net
> Subject: [scribus] Python scripter - scribus.setFont() and scribus.setTextAlignment() ? -- Solution
>
> I somehow lost this email from my client, but here it is copied from the
> Archives:
> *************************
> 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...
Arial is a Windows font, and some Linux systems do not have it.
I have the code below in one of my test scripts.
try:
scribus.setFont("Arial Regular", txt)
except:
try:
scribus.setFont("FreeSans Medium", txt)
except:
pass
Regards,William
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scribus.net/pipermail/scribus/attachments/20150604/92893c02/attachment.html>
More information about the scribus
mailing list