[scribus] How can I add an automatic page number into a text frame in a Python script (solved)
Andreas Huennebeck
acmh at gmx.de
Thu May 13 13:08:38 CEST 2010
Am Dienstag, 11. Mai 2010 schrieb Gregory Pittman:
> On 05/11/2010 10:51 AM, Henry Hartley wrote:
> > Andreas Huennebeck wrote:
> >>> I'm writing a Python script which creates a text frame which
> >>> should contain an automatic page number. In the Scribus GUI
> >>> one can do this with Ctrl-Alt-Shift-P, but simply calling
> >>> scribus.setText('#') in the Python script does not work
> >>> (of course). Is there a way to create a Python string with
> >>> special characters?
> >
> > Does currentPage(...) give you what you want?
No.
> I think what he wants is to be able to enter the page number character
> using Scripter.
Right.
> Looking at an SLA file, I see that this is encoded as <var
> name="pageno"/> (if it were some control-character so that you could
> enter it from python, it would likely cause the XML to be not
> well-formed), so you're not going to be able to do this from Scripter.
Here it is encoded as '' (scibus 1.3.3.12). However setText('')
results in '&#x1e;' because setText converts the '&'.
But I found the solution by using getText() to read an automatic page number
to find out how it is encoded in Python: it is '\x1e', and setText('\x1e')
inserts the automatic page number. Thanks for the idea to look into the sla
file!
I'm not sure if this solution works in later versions of scribus as well though.
> Generally what seems easiest is to make page numbering part of a Master
> Page, which can be applied or not, depending on your layout, and could
> be done after your document gets created by your script.
That was my first approach but all items on a master page are always in
the background and I wanted the pagenumber on top of an image.
> Also to consider: saving a page number text frame to the scrapbook (with
> the page numbering character), then right-clicking on the item in the
> Scrapbook, and Paste to Page, which will place it at the proper coordinates.
'Paste to Page' does not exist here.
> As with a large number of operations in Scribus there are many way to
> accomplish some specific task.
Yep.
bye
Andreas
--
Andreas Hünnebeck | email: acmh at gmx.de
----- privat ---- | www : http://www.huennebeck-online.de
GPG-Key: http://www.huennebeck-online.de/public_keys/andreas.asc
PGP-Key: http://www.huennebeck-online.de/public_keys/pgp_andreas.asc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scribus.net/pipermail/scribus/attachments/20100513/1fd7150b/attachment.htm>
More information about the scribus
mailing list