[scribus] scribus script to write current document name
José Antonio Rocha
joseantoniorocha at gmail.com
Sun Dec 12 21:00:54 CET 2010
2010/12/12 michael biggs <mjbiggs at hotmail.com>
>
> Hello José
>
> that is an excellent solution - exactly what I was seeking.
>
> have tried it and it works.
>
> great to know about listing undocumented functions via Scripter Console
> too.
>
> thanks very much
>
> Mike
>
You're welcome!
I don't know this command too, until seek for via console dir().
It makes possible get style settings directly from SLA file (there's no
build-in command for that), using Python module *xml.parsers.expat*
I need this to resize headline frames according headlines spaces above and
below and linespaces :
import xml.parsers.expat
styles = {}
charstyles = {}
def start_element(name, attrs):
#print 'Start element:', name, attrs
if name == 'STYLE':
styles[attrs[u'NAME']] = attrs
if name == 'CHARSTYLE':
charstyles[attrs[u'CNAME']] = attrs
def getParagraphStyle(styleName):
'''Return a dictionary with paragraph style parameters.'''
try:
res = styles[styleName]
except:
print styleName,'not in style sheet.'
res = ''
return res
def getStyleLineSpacing(styleName):
dic = getParagraphStyle(styleName)
if (dic == {}):
res = ''
else:
res = int(dic['LINESP'])
return res
def getStyleSpaceAbove(styleName):
dic = getParagraphStyle(styleName)
if dic == {}:
res = ''
else:
res = int(dic['VOR'])
return res
def getStyleSpaceBelow(styleName):
dic = getParagraphStyle(styleName)
if dic == {}:
res = ''
else:
res = int(dic['NACH'])
return res
def getStyleLineSpaceMode(styleName):
'''0=fixed, 1=proportional'''
dic = getParagraphStyle(styleName)
if dic == {}:
res = ''
else:
res = int(dic['LINESPMode'])
return res
p = xml.parsers.expat.ParserCreate('UTF-8')
p.StartElementHandler = start_element
*docName = scribus.getDocName()*
file = open(docName,'r')
p.ParseFile(file)
file.close()
# tests:
print styles
print charstyles
print getStyleLineSpacing(u'Head 1')
--
------------------------------
[image: Meira]nome: "José Antonio Meira da Rocha" tratamento: "Prof. MS."
cargo: "Coordenador do Curso de Relações Públicas Multimídia"
ies: "CESNORS/Universidade Federal de Santa Maria"
googletalk: email: MSN: joseantoniorocha at gmail.com
ICQ: 658222 Skype: "meiradarocha_jor"
veículo: [ http://meiradarocha.jor.br ]
fone: (55) 9651-0686
------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scribus.net/pipermail/scribus/attachments/20101212/74caedc4/attachment.htm>
More information about the scribus
mailing list