[Scribus] Scripter using Python calendar modules - prcal, prmonth

Dion Vansevenant diovan
Sun Aug 20 17:29:04 CEST 2006


I am playing around with Scribus, and am quite intrigued by the
possibilities it presents. Having been a long-time word processor user it's
interesting to learn the similarities and differences between what I am used
to, and the "right" way of doing page layout. It's a welcome challenge.

One thing I'd like to do is make my own day planner. I bought one from a
store that is close to what works for me, but I want to make my own to
incorporate my changes.

One of those changes is to display small calendars at the top of each page:
previous, current, and next month.

I've looked at other calendar scripts provided by the Scribus community, but
find them quite complex to adjust for my needs.

While reading up on the Scribus Scripter and its use of Python, I came
across the Python calendar module. What I'd really like to do is use the
output from prmonth to populate my mini calendars, but can't seem to get the
data in.

In the Script Console (nice feature, by the way!), I entered this:

import calendar
newDoc(PAPER_LETTER, (50, 10, 10, 10), PORTRAIT, 1, UNIT_POINTS,
FACINGPAGES, FIRSTPAGERIGHT)
cal = calendar.prmonth(2006,8)
ob = createText(100, 60, 140, 130)
setText(cal, ob)


When I ran it, I got a new document, and empty text box, and the following
console output:

1
    August 2006
Mo Tu We Th Fr Sa Su
    1  2  3  4  5  6
 7  8  9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Traceback (most recent call last):
  File "<console>", line 1, in ?
TypeError: coercing to Unicode: need string or buffer, NoneType found

It would seem that setText needs a string, so I changed that line from:

setText(cal, ob)

to:

setText(str(cal), ob)

and ran again, getting this in the console:

1
    August 2006
Mo Tu We Th Fr Sa Su
    1  2  3  4  5  6
 7  8  9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31

But now my document has a text box with "None" in it.

I have limited programming knowledge, but can muddle my way through some
stuff. Is it possible to get the Scripter to use this output? If so, what am
I missing to use it properly?


Thanks in advance.

DionV
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://nashi.altmuehlnet.de/pipermail/scribus/attachments/20060820/d764f26d/attachment.html 



More information about the scribus mailing list