[scribus] scribus script to write current document name
michael biggs
mjbiggs at hotmail.com
Mon Dec 13 13:03:55 CET 2010
Thanks for that.
Must confess, will have to study your code for a while to figure out wots going on - close to the limit of my current understanding.
I did wonder though if maybe you could help once more.
I've been writing some scripts to manipulate objects, but they all rely on the default Basepoint position.
Do you know of a script function that will allow setting of the Basepoint?
(didn't notice it in the list when using dir() and F9 with Scripter console)
Regards
> From: joseantoniorocha at gmail.com
> Date: Sun, 12 Dec 2010 18:00:54 -0200
> To: scribus at lists.scribus.net
> Subject: Re: [scribus] scribus script to write current document name
>
> 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>
> _______________________________________________
> scribus mailing list
> scribus at lists.scribus.net
> http://lists.scribus.net/mailman/listinfo/scribus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scribus.net/pipermail/scribus/attachments/20101213/e92456e8/attachment.htm>
More information about the scribus
mailing list