[scribus] Patch submitted for Command Line Arguments to be passed to python script
JLuc
jluc at no-log.org
Sun Sep 13 17:14:02 UTC 2015
Arguments dont appear magicaly as variables :
they are to be found in argv
and main is required to get argv.
You should read again the wiki
(http://wiki.scribus.net/canvas/Command_line_scripts)
and study and understand the provided example
before trying to use this new feature.
And then proceed the same way to get the arguments.
Thanks in advance.
JLuc
Le 13/09/2015 17:13, Gregory Pittman a écrit :
> On 09/13/2015 10:28 AM, JLuc wrote:
>> Le 13/09/2015 16:03, Gregory Pittman a écrit :
>>> I have a script which requires a variable S (which in this case is a Zip
>>> code). It previously got this from a valueDialog. I commented out the
>>> valueDialog line.
>>> I tried to run it with
>>> scribus -g -py postnet.py --python-arg -S 40207
>>> and when it runs it tells me there is no value for S.
>>> Maybe I don't understand what a 'python-arg' is.
>>
>> did you test -S or S ?
>> plz share your script for better answers.
>>
>> if you pass -S, -S should be tested, not S
>> as demonstrated in the example script
>> and explained in the wiki article.
>>
>
> Here is my script. The only input needed is the variable S.
>
> Greg
>
> #!/usr/bin/env python
>
> # File: postnet3.py
> # originally 2006.03.06 Gregory Pittman
> # this version 2015.09.12
> # adds the correction code:
> # the sum of all the digits
> # must be divisible by 10
>
> import sys
> import scribus
>
> postcode =
> ['llsss','sssll','sslsl','sslls','slssl','slsls','sllss','lsssl','lssls','lslss']
> a = 1.44 #line width
> b="Black" #line color
> relx=47 #Start X
> rely=323 #Start Y
> correctnum = 0
>
> if scribus.newDocument(scribus.PAPER_LETTER,
> (10,10,20,20),scribus.PORTRAIT, 1, scribus.UNIT_POINTS,
> scribus.NOFACINGPAGES, scribus.FIRSTPAGERIGHT, 1):
> # S = scribus.valueDialog('Postnet Barcode','Enter your Zip or Zip+4')
> scribus.setRedraw(1)
> scribus.setUnit(0)
> d = scribus.createLine(relx,rely,relx+9,rely,) #Beginning long
> framing line
> scribus.setLineWidth(a, d)
> scribus.setLineColor(b, d)
> scribus.setFillColor(b, d)
> rely = rely + 3.4
> for x in S[0:]:
> if x.isdigit():
> xnum = int(x)
> correctnum += xnum # Building the sum of all the digits
> code = postcode[xnum]
> for y in code[0:]:
> if y == 'l':
> d = scribus.createLine(relx,rely,relx+9,rely,) #Long
> line
> scribus.setLineWidth(a, d)
> scribus.setLineColor(b, d)
> scribus.setFillColor(b, d)
> rely = rely + 3.4
> elif y == 's':
> d = scribus.createLine(relx,rely,relx+3.6,rely,)
> #short line
> scribus.setLineWidth(a, d)
> scribus.setLineColor(b, d)
> scribus.setFillColor(b, d)
> rely = rely + 3.4
> correctstr = str(correctnum) # Here is where the correction code is
> added
> correctdig = int(correctstr[-1])
> if correctdig != 0:
> correctdig = 10 - correctdig
> code = postcode[correctdig]
> for y in code[0:]:
> if y == 'l':
> d = scribus.createLine(relx,rely,relx+9,rely,) #Long line
> scribus.setLineWidth(a, d)
> scribus.setLineColor(b, d)
> scribus.setFillColor(b, d)
> rely = rely + 3.4
> elif y == 's':
> d = scribus.createLine(relx,rely,relx+3.6,rely,) #short line
> scribus.setLineWidth(a, d)
> scribus.setLineColor(b, d)
> scribus.setFillColor(b, d)
> rely = rely + 3.4
>
> d = scribus.createLine(relx,rely,relx+9,rely,) #Ending long framing line
> scribus.setLineWidth(a, d)
> scribus.setLineColor(b, d)
> scribus.setFillColor(b, d)
> scribus.redrawAll()
>
>
>
> ___
> 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
>
More information about the scribus
mailing list