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

Dion Vansevenant diovan
Mon Aug 21 14:17:46 CEST 2006


On 8/20/06, Craig Ringer <craig at postnewspapers.com.au> wrote:
>
> Craig Ringer wrote:
>
> > You need to find a function in the calendar module that _returns_ the
> > formatted calendar rather than printing it.
>

I eventually figured that out.

Turns out I needed "month", not "prmonth".

Here's what I have so far:

import calendar
import datetime
mytoday = datetime.datetime.today()
myyear = str(mytoday.year)
mymonth = str(mytoday.month)
newDoc(PAPER_LETTER, (50, 10, 10, 10), PORTRAIT, 1, UNIT_POINTS,
FACINGPAGES, FIRSTPAGERIGHT)
Objects=[]
calendar.setfirstweekday(calendar.SUNDAY)
curyear = int(valueDialog('Year', "Please enter the year:",myyear))
curmonth = int(valueDialog('Month', "Please enter the month:",mymonth))
#cal = calendar.month(myyear,mymonth)

prevmonth = curmonth-1
nextmonth = curmonth+1
#messageBox("Month", "Prev: "+str(prevmonth)+", Cur: "+str(curmonth)+",
Next: "+str(nextmonth))
x1 = 100
y1 = 60
width = 100
height = 78
gap = 5

for i in [prevmonth, curmonth, nextmonth]:
   messageBox("START Loop variable", "i is: "+str(i))
   cal = calendar.month(curyear,i)
   ob = createText(x1, y1, width, height)
   setFont('Courier 10 Pitch Regular',ob)
   setFontSize(8,ob)
   setLineColor('Black',ob)
   setLineWidth(0.5,ob)
   setLineShade(100,ob)
   setLineStyle(LINE_SOLID,ob)
   setText(cal,ob)
   messageBox("Wrote calendar for: "+str(i), "x1 is: "+str(x1))
   x1 += width+gap
   messageBox("Updated x1", "x1 is now: "+str(x1))
   messageBox("END Loop variable", "i is now: "+str(i))



Just working now on making it a little more flexible, to get it closer to
the top of the page, adjust for margin sizes, and leftpage/rightpage issues.

Thanks for the tips folks!

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



More information about the scribus mailing list