Scripter/Images

From Scribus Wiki
Revision as of 22:05, 12 February 2005 by Owencook (talk | contribs)
Jump to navigation Jump to search
This article is part of the Scripts series.

Haven't got this wiki thing psyched out yet, but here is a script to put an 8pt border 20 pts in on a A4 page. Modifyfying it gives all sorts of borders


from scribus import *

if NewDoc(Paper_A4, (10, 10, 10, 10), Portrait, 1, UNIT_POINTS, NoFacingPages, FirstPageRight):

       spx=20          # x co-ord Start point
       spy=20          # y co-ord Start point
       wth=595         # A4 width in points
       dph=842         # Depth of frame - adjust to suit
       a=8             # Line width
       b="Black"       # add other colors as required
       b1="Blue"
       w="White"
       h = CreateRect(spx,spy,wth-2*spx,dph-2*spy)
       setCornerRadius(20, h)
       setLineWidth(8, h)
       setFillColor(w, h)
       setLineColor(b, h)
       SaveDocAs("Border_2.sla")

When I last tried setCornerRadius didn't work, but they'll sort that out eventually.


Here is another border, pretty useless but at least I am learnt a bit about Python - the 'for' loops need their following lines to be indented. Also helps to understand the x and y co-ordinates of Scribus


from scribus import *

Margins = (10, 10, 10, 10)
if NewDoc(Paper_A4, Margins, Portrait, 1, Points, NoFacingPages, FirstPageRight):
#some constants
a = 5						#line width
b="Blue"
m=33						#Fill shade, integer 0-100
g60="Grey60"
spx=30						#Start X
spy=30						#Start Y
a4w=595					        #Width A4 getPageSize ?
a4d=842					        #depth A4 getPageSize ?
#Draw the lines
d = CreateLine(spx-a/2,spy,a4w-30+a/2,spy)	#Top
setLineColor(g60, d)
setLineWidth(a, d)
e = CreateLine(spx,spy,spx,a4d-27)		#LH vertical
setLineWidth(a, e)
setLineColor(g60, e)
f = CreateLine(a4w-30,spy,a4w-30,a4d-27)	#RH vertical
setLineWidth(a, f)
setLineColor(g60, f)
g = CreateLine(spx-a/2,a4d-27,a4w-30+a/2,a4d-27)#Bottom
setLineWidth(a, g)
setLineColor(g60, g)
#Draw the "holes"
for i in range(0,int(770/10)):
  l = CreateRect(spx+5,spy+10+10*i,10,5)
  setFillShade(m,l)
  setLineColor(g60,l)		
for i in range(0,int(770/10)):
  k = CreateRect(a4w-45,spy+10+10*i,10,5)
  setFillShade(m,k)		
  setLineColor(g60,k)
SaveDocAs("Fancy_border.sla")