Calendar module: HTMLCalendar overrides style sheet settings

Terry Reedy tjreedy at
Thu Mar 26 22:21:27 CET 2009

Sibylle Koczian wrote:
> Hello,
> I want to create a calendar with special text and background color for
> holidays and some other dates. This is for printing, but a HTML file
> seems a good choice, independent of changing text processing software
> and easier to code with Python than a script which fills in a Word or
> OpenOffice template.
> So I looked into the calendar module and made a LocalHTMLCalendar
> subclass. Putting in additional style classes for "my" dates wasn't
> difficult, but there is one thing I don't like at all: the methods
> formatmonth() and formatyear() both return tables with explicit and ugly
> formatting:
> <table border="0" cellpadding="0" cellspacing="0" class="month">
> and the same for class="year". This overrides the settings I make in the
> style sheet.
> Of course I can overwrite these methods, but why do it like this? The
> output is made for use with a style sheet, so why use direct formatting
> at this point?

Calendar is an ancient and not-well-maintained module which may even 
predate html.  (There have even been suggestions that it be dropped.) I 
would not be surprised if the 'css' parameter of formatyearpage were an 
incomplete addition to the first version of HTMLCalendar.  Feel free to 
submit a patch to make the html work better with css, as long as css is 
not made mandatory rather than optional.  (Or should there be two html 
classes? I do not know html well enough to know.)


More information about the Python-list mailing list