[scribus] PDFfile causes looping to fail?
Jerry Stratton
scribusjerry at hoboes.com
Tue Feb 26 19:48:08 UTC 2019
On Feb 26, 2019, at 12:33 PM, Gregory Pittman <gpittman at iglou.com> wrote:
> I find that this works in 1.5.8svn, so perhaps the thing to do is upgrade your Scribus version. Have you tried adding more parameters to the messageBox() command? It seems the problem has something to do with it. Not sure why you want to make 3 messageBoxes on top of each other.
Well, of course, I don’t want three messageBoxes. The point was to make a simplified script that still produced the error; here’s a simpler one that does not use messageBox and still produces the error when I run it:
import scribus
countDown = ['three', 'two', 'one']
pdf = scribus.PDFfile()
for counter in countDown:
pass
Traceback (most recent call last):
File "<string>", line 8, in <module>
File "/Users/jerry/bin/Scribus/testPDF.py", line 4, in <module>
for counter in countDown:
IndexError: list assignment index out of range
Unless it’s too buggy to use, I’d like to stay with the stable version. Is 1.4.7 too buggy to use, or is there a way around this problem?
This is the actual script, and the error it produces:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import scribus
import os
#don't do anything unless there's a document open
if scribus.haveDoc():
#get the folder to save to
saveTo = scribus.fileDialog('Folder to save characters to:', isdir=True, issave=True)
if saveTo:
#deselect, or it will only print the current selection
scribus.deselectAll()
layers = scribus.getLayers()
#first, make sure only the background is set to print
for layer in layers:
if layer == 'Background':
scribus.setLayerPrintable(layer, True)
else:
scribus.setLayerPrintable(layer, False)
#now, go through each non-background layer and export as PDF
exporter = scribus.PDFfile()
for layer in layers:
if layer != 'Background':
scribus.setLayerPrintable(layer, True)
filePath = os.path.join(saveTo, layer + '.pdf')
exporter.file = filePath
exporter.save()
scribus.setLayerPrintable(layer, False)
else:
scribus.messageBox("No Open Document", "You need to have a document open to save it as PDF.”)
Traceback (most recent call last):
File "<string>", line 8, in <module>
File "/Users/jerry/bin/Scribus/printLayers.py", line 29, in <module>
filePath = os.path.join(saveTo, layer + u'.pdf')
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.7/posixpath.py", line 67, in join
for b in p:
IndexError: list assignment index out of range
If I remove os.path.join line and replace it with string concatenation, I get the same error but at the end of the loop through the layers:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import scribus
import os
#don't do anything unless there's a document open
if scribus.haveDoc():
#get the folder to save to
saveTo = scribus.fileDialog('Folder to save characters to:', isdir=True, issave=True)
if saveTo:
#deselect, or it will only print the current selection
scribus.deselectAll()
layers = scribus.getLayers()
#first, make sure only the background is set to print
for layer in layers:
if layer == 'Background':
scribus.setLayerPrintable(layer, True)
else:
scribus.setLayerPrintable(layer, False)
#now, go through each non-background layer and export as PDF
exporter = scribus.PDFfile()
for layer in layers:
if layer != 'Background':
scribus.setLayerPrintable(layer, True)
filePath = saveTo + '/' + layer + '.pdf'
exporter.file = filePath
exporter.save()
scribus.setLayerPrintable(layer, False)
else:
scribus.messageBox("No Open Document", "You need to have a document open to save it as PDF.")
Traceback (most recent call last):
File "<string>", line 8, in <module>
File "/Users/jerry/bin/Scribus/printLayers.py", line 26, in <module>
for layer in layers:
IndexError: list assignment index out of range
Jerry
http://www.hoboes.com/Mimsy/
"After midnight, all things are possible."
More information about the scribus
mailing list