[Doc-SIG] Re: PythonPoint front-end
Aahz
aahz@pythoncraft.com
Sat, 26 Apr 2003 10:05:55 -0400
--AhhlLboLdkugWU4S
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
On Fri, Apr 25, 2003, Kevin Altis wrote:
>
> Hey Aahz,
> I couldn't get the script to run.
>
> ImportError: No module named style
Oops. I've only run this as part of the PythonPoint toolchain, so I
forgot about that. I've long since had to run PythonPoint only with a
style file, so my stx2xml partly relies on that.
I'm attaching the style.py that I used.
> What are the module/package requirements? Do you have a URL to the PDF
> output so I can just look at that?
Real Soon Now. ;-) (It's part of my full PyCon package.)
> The thing I was thinking of doing would be pretty darn simple, so it would
> be interesting to get your requirements for the presentation tool/output
> since I haven't done many presentations. I'm sort of leaning towards wiki
> pages with some special CSS style sheets.
Well, I don't like web pages much, so that doesn't work for me. I chose
this route because I needed the fine-grained control. (Just like
PowerPoint.)
--
Aahz (aahz@pythoncraft.com) <*> http://www.pythoncraft.com/
"In many ways, it's a dull language, borrowing solid old concepts from
many other languages & styles: boring syntax, unsurprising semantics,
few automatic coercions, etc etc. But that's one of the things I like
about it." --Tim Peters on Python, 16 Sep 93
--AhhlLboLdkugWU4S
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="style.py"
#from reportlab.platypus import TableStyle
from reportlab.platypus.tables import TableStyle
from reportlab.lib import styles
from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_RIGHT, TA_JUSTIFY
from reportlab.lib import colors
def Styles():
stylesheet = {}
ParagraphStyle = styles.ParagraphStyle
para = ParagraphStyle('Normal', None) #the ancestor of all
para.fontName = 'Times-Roman'
para.fontSize = 30
para.leading = para.fontSize * 1.2
stylesheet['Normal'] = para
stylesheet['normal'] = para
#This one is spaced out a bit...
para = ParagraphStyle('BodyText', stylesheet['Normal'])
para.spaceBefore = 12
stylesheet['BodyText'] = para
para = ParagraphStyle('Centered', stylesheet['Normal'])
para.alignment = TA_CENTER
stylesheet['Centered'] = para
para = ParagraphStyle('BigCentered', stylesheet['Normal'])
para.spaceBefore = 12
para.alignment = TA_CENTER
stylesheet['BigCentered'] = para
para = ParagraphStyle('Italic', stylesheet['BodyText'])
para.fontName = 'Times-Italic'
stylesheet['Italic'] = para
para = ParagraphStyle('Footer', stylesheet['Normal'])
para.fontSize = 18
para.leading = 0
para.alignment = TA_RIGHT
stylesheet['Footer'] = para
para = ParagraphStyle('Title', stylesheet['Normal'])
para.fontName = 'Times-Roman'
para.fontSize = para.fontSize * 3.0
para.leading = para.fontSize * 1.0
para.spaceAfter = para.fontSize * 0.2
para.alignment = TA_CENTER
stylesheet['Title'] = para
stylesheet['title'] = para
para = ParagraphStyle('SmallTitle', stylesheet['Normal'])
para.fontName = 'Times-Roman'
para.fontSize = stylesheet['Title'].fontSize * 0.5
para.leading = para.fontSize * 1.0
para.alignment = TA_CENTER
stylesheet['SmallTitle'] = para
stylesheet['smalltitle'] = para
para = ParagraphStyle('Heading1', stylesheet['Normal'])
para.fontName = 'Times-Bold'
para.fontSize = para.fontSize * 2.25
para.leading = para.fontSize * 1.1
para.spaceAfter = para.fontSize * 0.15
para.alignment = TA_CENTER
stylesheet['Heading1'] = para
stylesheet['head'] = para
para = ParagraphStyle('Heading2', stylesheet['Normal'])
para.fontName = 'Times-Bold'
para.fontSize = para.fontSize * 1.6
para.leading = para.fontSize * 1.2
para.spaceBefore = para.fontSize * 0.8
stylesheet['Heading2'] = para
para = ParagraphStyle('Heading3', stylesheet['Normal'])
para.fontName = 'Times-BoldItalic'
para.spaceBefore = 24
stylesheet['Heading3'] = para
para = ParagraphStyle('Heading4', stylesheet['Normal'])
para.fontName = 'Times-BoldItalic'
para.spaceBefore = 6
stylesheet['Heading4'] = para
para = ParagraphStyle('Bullet', stylesheet['Normal'])
para.firstLineIndent = 10
para.leftIndent = 16
para.fontSize = para.fontSize * 1.5
para.leading = para.fontSize * 1.1
para.spaceBefore = para.fontSize * 0.4
para.bulletFontName = 'Symbol'
para.bulletFontSize = para.fontSize * 0.7
para.bulletIndent = 20
stylesheet['Bullet'] = para
stylesheet['bullet'] = para # doesn't work
#Indented, for lists
para = ParagraphStyle('Indent', stylesheet['Normal'])
para.fontSize = stylesheet['Bullet'].fontSize * 0.75
para.leftIndent = para.fontSize * 2.5
para.leading = para.fontSize * 1.1
para.spaceBefore = para.fontSize * 0.2
stylesheet['Indent'] = para
stylesheet['indent'] = para
para = ParagraphStyle('Definition', stylesheet['Normal'])
#use this for definition lists
para.firstLineIndent = 72
para.leftIndent = 72
para.bulletIndent = 0
para.spaceBefore = 12
para.bulletFontName = 'Helvetica-BoldOblique'
para.bulletFontSize = 24
stylesheet['Definition'] = para
para = ParagraphStyle('Code', stylesheet['Normal'])
para.fontName = 'Courier'
#para.fontSize = para.fontSize * 0.75
para.fontSize = para.fontSize * 0.8
para.leading = para.fontSize + 1
para.leftIndent = 36
stylesheet['Code'] = para
stylesheet['code'] = para
para = ParagraphStyle('CodeHeader', stylesheet['Normal'])
para.fontSize = stylesheet['Code'].fontSize * 1.5
para.spaceAfter = para.fontSize * 0.2
para.leftIndent = 36
para.firstLineIndent = para.leftIndent
stylesheet['CodeHeader'] = para
para = ParagraphStyle('NumList', stylesheet['Normal'])
para.fontSize = 24
para.leading = para.fontSize * 1.1
stylesheet['NumList'] = para
para = ParagraphStyle('URL', stylesheet['Normal'])
para.fontName = 'Courier'
para.fontSize = 24
para.leading = para.fontSize + 2
para.leftIndent = 10
stylesheet['url'] = para
para = ParagraphStyle('Small', stylesheet['Normal'])
para.fontSize = 12
para.leading = 14
stylesheet['Small'] = para
#now for a table
ts = TableStyle([
('FONT', (0,0), (-1,-1), 'Times-Roman', 24),
('LINEABOVE', (0,0), (-1,0), 2, colors.green),
('LINEABOVE', (0,1), (-1,-1), 0.25, colors.black),
('LINEBELOW', (0,-1), (-1,-1), 2, colors.green),
('LINEBEFORE', (-1,0), (-1,-1), 2, colors.black),
('ALIGN', (1,1), (-1,-1), 'RIGHT'), #all numeric cells right aligned
('TEXTCOLOR', (0,1), (0,-1), colors.red),
('BACKGROUND', (0,0), (-1,0), colors.Color(0,0.7,0.7))
])
stylesheet['table1'] = ts
para = stylesheet['Code']
ts = TableStyle([
('FONT', (0,0), (-1,0), 'Times-Roman', para.fontSize*1.5 ),
('FONT', (0,1), (-1,-1), 'Courier', para.fontSize),
])
stylesheet['2code'] = ts
return stylesheet
--AhhlLboLdkugWU4S--