[scribus] PDFfile causes looping to fail?

ZASKE Martin zm at revue-gugu.org
Tue Feb 26 22:37:32 UTC 2019


Oops, I lied, I do not get THAT error message, I get AN error message.

But when I correct the quotes in line 35 than I get NO errors.

If you give us a sample file and a summary what your script is supposed
to do, then I will test more. Unless you are not interested whether
Scribus scripting works great on Windows 10.

Martin



On 26.02.2019 20:48, Jerry Stratton wrote:
> 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."
> 
> ___
> Scribus Mailing List: scribus at lists.scribus.net
> Edit your options or unsubscribe:
> http://lists.scribus.net/mailman/listinfo/scribus
> See also:
> http://wiki.scribus.net
> http://forums.scribus.net
> 


-- 
ZASKE Martin
responsable GʊGʊ
BP 50 - Bassila - Bénin
tel GʊGʊ 66.66.11.11
tel pers 97.44.62.95



More information about the scribus mailing list