[Scribus] Perhaps another stupid question ...

Pierre Marchand capparis
Sun Apr 9 16:08:35 CEST 2006


Le Sat, 08 Apr 2006 16:28:11 +0200, Thomas Zastrow
<listen at thomas-zastrow.de> m'a transmis le message suivant :

> Louis, is there another way to create a lot of pages with automatic 
> (chained) text-frames on them? The task is to import a long piece of 
> text which needs a lot of pages (app. 100 pages). I'm too lazy to
> create each page manually, adding text-frames, chaining them
> together .. ;-)
Scribus' script can do that. I repost here an example that works for me.

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

""" Create text frames on all pages """

import sys


try:
	from scribus import *
except ImportError:
	print "This script only runs from within Scribus."
	sys.exit(1)
		

if haveDoc():
	page = long(valueDialog('Begin','Where I begin ?')) 
	end = long(valueDialog('End','Where I stop ?'))
	xp = float(valueDialog('x value', 'Please give me an x value for even pages')) 
	yp = float(valueDialog('y value', 'Please give me an y value for even pages')) 
	wp = float(valueDialog('w value', 'Please give me an width value for even pages'))  
	hp = float(valueDialog('h value', 'Please give me an height value for even pages')) 
	#messageBox("parametres", str([xp,yp,wp,hp]))
	xi = float(valueDialog('x value', 'Please give me an x value for odd pages')) 
	yi = float(valueDialog('y value', 'Please give me an y value for odd pages')) 
	wi = float(valueDialog('w value', 'Please give me an width value for odd  pages')) 
	hi = float(valueDialog('h value', 'Please give me an height value for odd  pages')) 
 	names=[]
	
	while page <= end :
		if page % 2 == 0 :
			try:
				gotoPage(page)
				names.append(createText(xp, yp, wp, hp))
				lockObject(names[-1])
			except  IndexError :
				break
		else:
			try:
				gotoPage(page)
				names.append(createText(xi, yi, wi, hi))
				lockObject(names[-1])
				
			except  IndexError :
				break
		page += 1

	for n in range(len(names) - 1) :
		try :
			linkTextFrames(names[n], names[n+1])
			
		except ScribusException :
			messageBox("Erreur", "Due to error, linking of text frames is left unfinished", ICON_WARNING )
			break


	
else:
        messageBox(TITLE, "No document open", ICON_WARNING)
-----------------------------------------------------------------------------------------



-- 
Pierre Marchand
JabberId : capparis at im.apinc.org



More information about the scribus mailing list