Drawing Lines and Python "For loops": Difference between revisions
Jump to navigation
Jump to search
(Need an indented block after the "if NewDoc") |
m (Updated to reflect (new?) API) |
||
Line 6: | Line 6: | ||
Introduces: CreateLine SetLineWidth SetLineColor and Python for loops. | Introduces: CreateLine SetLineWidth SetLineColor and Python for loops. | ||
<pre><nowiki> | <pre><nowiki> | ||
from scribus import * | |||
Margins = (10, 10, 10, 10) | |||
if newDoc(PAPER_A4, Margins, PORTRAIT, 1, UNIT_POINTS, NOFACINGPAGES, | |||
FIRSTPAGERIGHT): | |||
#some constants | #some constants | ||
Line 21: | Line 22: | ||
#Draw the lines | #Draw the lines | ||
d = | d = createLine(spx-a/2,spy,a4w-30+a/2,spy) #Top | ||
setLineColor(g60, d) | setLineColor(g60, d) | ||
setLineWidth(a, d) | setLineWidth(a, d) | ||
e = | e = createLine(spx,spy,spx,a4d-27) #LH vertical | ||
setLineWidth(a, e) | setLineWidth(a, e) | ||
setLineColor(g60, e) | setLineColor(g60, e) | ||
f = | f = createLine(a4w-30,spy,a4w-30,a4d-27) #RH vertical | ||
setLineWidth(a, f) | setLineWidth(a, f) | ||
setLineColor(g60, f) | setLineColor(g60, f) | ||
g = | g = createLine(spx-a/2,a4d-27,a4w-30+a/2,a4d-27)#Bottom | ||
setLineWidth(a, g) | setLineWidth(a, g) | ||
setLineColor(g60, g) | setLineColor(g60, g) | ||
Line 36: | Line 37: | ||
#Draw the "holes" | #Draw the "holes" | ||
for i in range(0,int(770/10)): | 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)): | 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") #Make sure this is writable | |||
</nowiki></pre> | </nowiki></pre> |
Revision as of 08:56, 16 June 2007
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
Introduces: CreateLine SetLineWidth SetLineColor and Python for loops.
from scribus import * Margins = (10, 10, 10, 10) if newDoc(PAPER_A4, Margins, PORTRAIT, 1, UNIT_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") #Make sure this is writable