SamAgenda - a Scribus script for planners

Simple "ruled week on two pages" planner creation wizard for Scribus.
It creates an agenda for a given year and a given language in the Filofax Personal format, on a A4 page, three sheets per page. Just cut and punch the sheets, and close them into the binder.

DESCRIPTION & USAGE:
It's a python script that automates the process of creation a planner in Scribus.
Just unzip the script and copy it into the directory ~\usr\share\scribus\scripts\ (or something similar, depending on your operating system). This way you will have in Scribus a new menu item into the menu [Script] - [Scribus Scripts] : 'SamAgenda'. Click on it and enjoy.

This script take a bit longer time to elaborate the full document, so don't be hurry. Take a look at the progressbar at the bottom of the Scribus main window.

In the "Eng2010.pdf.zip" attachment you can see an example of what i've done in scribus with my script in just 25 seconds: a complete english planner for the year 2010.

Every comment or suggestion is welcome!.

Update: version 0.2
- Discarded the 'calendar' module importation. The standard python module 'calendar.py' seems to be not fully updated on some operating systems (thanks to ygor at diyplanner.com for his great collaboration).
- Added a counter at the upper right side of the page.
- Some minor bugs resolution and cosmethic changes.

Paper size: 
Other
Thumbnail: 
example.jpeg
Usage advice: 

Script for Scribus.
Scribus is an Open Source program that brings award-winning professional page layout to Linux/UNIX, Mac OS X, OS/2 Warp 4/eComStation and Windows desktops with a combination of "press-ready" output and new approaches to page layout.
Underneath the modern and user friendly interface, Scribus supports professional publishing features, such as CMYK color, separations, Spot Colors, ICC color management and versatile PDF creation. (from the Scribus site).

License: 
GPL
Language: 
python
Applications required: 
Scribus; any pdf viewer; the font "Century Schoolbook L"
AttachmentSize
Eng2010.pdf.zip150.11 KB
SamAgenda02.zip5.42 KB
Syndicate content

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Script does not work

Traceback (most recent call last):
  File "", line 8, in ?
  File "/Users/igor/Desktop/SamAgenda.py", line 221
     StartLines = (R_LINE_X + (C * LINE_X_OFFSET) for C in range(COLUMNS))
                                                    ^
 SyntaxError: invalid syntax
python 2.5.1 and Scribus 1.3.8 running on an Intel iMac running MacOS X 10.5.8
-------------------------------------------------------------------------------------------------
"I think the surest sign that there is intelligent life out there in the universe is that none of it has tried to contact us."
(Calvin and Hobbes/Bill Waterson) ***

I cannot see the error

Thanks for your report.

That line is a 'list comprehension', that "... become part of the Python language with release 2.0" (google "python pep 0202", first result).

The thing I can do is to repost the script, the same script that I'm using and working with python 2.6.5, Scribus 1.3.3.13svn, Ubuntu 10.04.

Don't run the script from the desktop. Copy it into the scripts folder into the scribus installation directory.

let's try this way

please try to replace the line 221:

StartLines = (R_LINE_X + (C * LINE_X_OFFSET) for C in range(COLUMNS))

with this one:

StartLines = list(R_LINE_X + (C * LINE_X_OFFSET) for C in range(COLUMNS))

then replace the line 224:

StartLines = (L_LINE_X + (C * LINE_X_OFFSET) for C in range(COLUMNS))

with this one:

StartLines = list(L_LINE_X + (C * LINE_X_OFFSET) for C in range(COLUMNS))

and then let me know.

Many thanks.

Still does not work

I tried your script change, and I tried updating to Python 2.7, and I get the same error.

It is pointing to the word "for"

I think I see what it is supposed to be doing.
StartLines is supposed to be a list of values of R_LINE_X + (C * LINE_X_OFFSET) with C being a "list" of values of 1..columns

Interesting that this runs on your Ubuntu machine, and it won't run on my Mac
-----------------------------------
"I think the surest sign that there is intelligent life out there in the universe is that none of it has tried to contact us." (Calvin and Hobbes/Bill Waterson) ***

It's incredible...

The "list comprehension" is a common way to map and filter lists in python. It became a standard with Python 2.0 and later.
On pep 202 (google "python pep 0202"; first result) there are some examples of that tecnique. One of the simplest is:

>>> print [i for i in range(20) if i%2 == 0]
[0, 2, 4, 6, 8, 10, 12, 14, 16, 18]

I've reproduced the line that doesn't work on your system in a session of IDLE. This is the code:

Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
[GCC 4.4.3] on linux2
Type "copyright", "credits" or "license()" for more information.

***************************************************************
Personal firewall software may warn about the connection IDLE
makes to its subprocess using this computer's internal loopback
interface. This connection is not visible on any external
interface and no data is sent to or received from the Internet.
***************************************************************
IDLE 2.6.5 ==== No Subprocess ====
>>> R_LINE_X = 15
>>> LINE_X_OFFSET = 20
>>> COLUMNS = 7
>>> StartLines = list(R_LINE_X + (C * LINE_X_OFFSET) for C in range(COLUMNS))
>>> print StartLines
[15, 35, 55, 75, 95, 115, 135]
>>>

As you can see, it works.

Same story running python in console:

sam@qasbah-desktop:~$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> R_LINE_X = 15
>>> LINE_X_OFFSET = 20
>>> COLUMNS = 7
>>> StartLines = list(R_LINE_X + (C * LINE_X_OFFSET) for C in range(COLUMNS))
>>> print StartLines
[15, 35, 55, 75, 95, 115, 135]
>>>

I wish have an opinion from people who have tried the script on other operating systems.

Regards.

Works fine on my OpenSuse 11.3

My current system: OpenSuse 11.3; Kernel 26.34; python 2.6.5; Scribus 1.3.3.14

Congretulations for a good piece of codework!

what version are you using?

Thanks for your report.

What version are you using? SamAgenda.py or the test version, SamAgenda02.py?

----------------------------------------

Your boss climbed the corporate ladder, wrong by wrong.

It was SamAgenda.py

and your newer version 0.2 works also.

Thanks again

Got past that one to a new one

I finally got past the syntax error by doing this:

Change
		StartLines = list( R_LINE_X + (C * LINE_X_OFFSET) for C in range(COLUMNS))
to
		StartLines = list( [R_LINE_X + (C * LINE_X_OFFSET) for C in range(COLUMNS)])

And I found where the other scripts "live" (inside the application bundle), so I put a copy there and then got this:

Traceback (most recent call last):
  File "", line 8, in ?
  File "/Applications/Scribus.app/Contents/share/scribus/scripts/Agenda.py", line 185, in ?
    class cal(calendar.Calendar):
AttributeError: 'module' object has no attribute 'Calendar'

Apparently, it is not finding "Calendar"

I see the lines:

import sys
import calendar
import datetime
from time import localtime

Where is it supposed to be importing these from ? Scribus ? Python ?
-----------------------------------
"I think the surest sign that there is intelligent life out there in the universe is that none of it has tried to contact us." (Calvin and Hobbes/Bill Waterson) ***

let's see...

Try this:
-) Open Scribus;
-) Menu [Script] - [Show Console];
-) In the upper pane of the console type:

import sys
sys.path
import calendar
dir(calendar)

-) Console menu [Script] - [Run]
-) In the bottom pane you should see the result. Copy and paste here.

Regards.

-------------------------------

Your boss climbed the corporate ladder, wrong by wrong.

Results

'Scribus Python Console

This is a standard Python console with some
known limitations. Please consult the Scribus
Scripter documentation for futher information. '
['/Applications/Scribus.app/Contents/share/scribus/scripts/',
'/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3',
'/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/plat-darwin', 
'/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/plat-mac', 
'/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/plat-mac/lib-scriptpackages', 
'/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/lib-tk',
'/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/lib-dynload', 
'/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages']

-----------------------------------
"I think the surest sign that there is intelligent life out there in the universe is that none of it has tried to contact us." (Calvin and Hobbes/Bill Waterson) ***

about SamAgenda on MacOs

@ygor: Sorry for the delay.

"calendar" is a standard python module. From version 2.5 it contains the class "Calendar" (google "python calendar module", first result).

Take a look at your shell path, and control that exists the location /Library/Frameworks/Python.framework. That line should have been created while updating to Python 2.7.

Please find on your system the file 'calendar.py' (it should be in /System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3, but im not sure; it could be also in /Library/Frameworks/Python.framework)
There's a 'calendar.py' also in the wxWidgets package that is not the right one, so be careful.

If 'calendar.py' is in /System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3 do as follows:

-) Open Scribus; menu [Script] - [Show Console];
-) In the upper pane of the console type:

import calendar
dir(calendar)

-) The result should be something like
['Calendar', 'EPOCH', 'FRIDAY', 'February', 'HTMLCalendar', ...]
-) If you don't see the word 'Calendar' (capital first letter) in the list, then you should update your full python library to the version 2.5.

If 'calendar.py' IS NOT in /System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3 do as follows:

-) In the upper pane of the console type:

import sys
sys.path.append('path/to/your/calendar.py/file/without/filename')
import calendar
dir(calendar)

then as above. If you can, please copy and past here the results of the scripts.

p.s.: which tag do you use to print code on silver background?

-----------------------------------
Your boss climbed the corporate ladder, wrong by wrong.

results

... using the "pre" tag and Full HTML input format ...

import calendar
dir(calendar)

returns

'Scribus Python Console

This is a standard Python console with some \nknown limitations. Please consult the Scribus
Scripter documentation for futher information. '
[
 'EPOCH', 'FRIDAY', 'February', 'January', 'MONDAY', 'SATURDAY', 'SUNDAY', 'THURSDAY', 'TUESDAY', 'WEDNESDAY',
 '_EPOCH_ORD', '__all__', '__builtins__', '__doc__', '__file__', '__name__', '_colwidth', '_firstweekday', '_localized_day',
 '_localized_month', '_spacing', 'calendar', 'datetime', 'day_abbr', 'day_name', 'error', 'firstweekday', 'format3c', 'format3cstring',
 'isleap', 'leapdays', 'mdays', 'month', 'month_abbr', 'month_name', 'monthcalendar', 'monthrange', 'prcal', 'prmonth', 'prweek',
 'setfirstweekday', 'timegm', 'week', 'weekday', 'weekheader'
]

The line wrapping is mine.
-----------------------------------
"I think the surest sign that there is intelligent life out there in the universe is that none of it has tried to contact us." (Calvin and Hobbes/Bill Waterson) ***

let's try a radical solution...

@ygor:

You have an old version of the python standard library. So let me try a radical solution: I've rewritten some lines of code in the script aiming to the end of eliminating the call to the 'calendar' module.

Please, download the file 'test.zip' that I've added on the 'templates' page of my script, try it and let me know. It works on my system but... let's cross the fingers.

-----------------------------------

Your boss climbed the corporate ladder, wrong by wrong.

It got further, but...

It asked for a year and a language, and then ...

Traceback (most recent call last):
  File "", line 8, in ?
  File "/Users/igor/Desktop/Scribus Agenda Python/SamAgenda02.py", line 213, in ?
    main()
  File "/Users/igor/Desktop/Scribus Agenda Python/SamAgenda02.py", line 205, in main
    drawAllPages(aYear, aLocal)
  File "/Users/igor/Desktop/Scribus Agenda Python/SamAgenda02.py", line 177, in drawAllPages
    CreateTexts('right', (2 + C), local, aTupleYear[3+(7*C):7+(7*C)])
  File "/Users/igor/Desktop/Scribus Agenda Python/SamAgenda02.py", line 144, in CreateTexts
    setFont(YEARMONTH_TEXT_FONT_NAME, YearMonthTextBox)
ValueError: Font not found.

-----------------------------------
"I think the surest sign that there is intelligent life out there in the universe is that none of it has tried to contact us." (Calvin and Hobbes/Bill Waterson) ***

That's the stack of error

That's the stack of error callings. You have to read the last call:

File "/Users/igor/Desktop/Scribus Agenda Python/SamAgenda02.py", line 144, in CreateTexts
setFont(YEARMONTH_TEXT_FONT_NAME, YearMonthTextBox)
ValueError: Font not found.

It should be the last error you can meet: at that point the script has run every loop once at least.

You have to install the font "Century Schoolbook L". Otherwise you can change by hand the font that is required: at the beginning of the script you can see a list of lines as the following:
YEARMONTH_TEXT_FONT_NAME = 'Century Schoolbook L Bold'
...
DAY_TEXT_FONT_NAME = 'Century Schoolbook L Bold'
...
WEEKDAY_TEXT_FONT_NAME = 'Century Schoolbook L Bold'

You can change the font, for example, in the following way:

YEARMONTH_TEXT_FONT_NAME = 'Times New Roman Bold'
...
DAY_TEXT_FONT_NAME = 'Times New Roman Regular'
...
WEEKDAY_TEXT_FONT_NAME = 'Times New Roman Regular'

This way everythig should work fine now.

Many thanks for your reports, and best regards.

---------------------------------------------

Your boss climbed the corporate ladder, wrong by wrong.

SamAgenda v0.2

Update: version 0.2
- Discarded the 'calendar' module importation. The standard python module 'calendar.py' seems to be not fully updated on some operating systems (thanks to ygor at diyplanner.com for his great collaboration).
- Added a counter at the upper corner of the page.
- Some minor bugs resolution and cosmethic changes.

--------------------------------------

Your boss climbed the corporate ladder, wrong by wrong.