1 # drawing hearts in the snow!
6 from odf
.style
import Style
, TextProperties
, ParagraphProperties
, BackgroundImage
, GraphicProperties
7 from odf
.draw
import Frame
, TextBox
9 from stylesheet
import *
13 def directory_structure():
14 genre
= ["brief", "gedicht", "verhaal"]
15 spice
= ["character", "dingbat", "image"]
17 "brief" : ["oesters", "nevels", "zon", "dromen", "rivieren", "toekan"],
18 "gedicht" : ["vulkanen", "souvenirs", "ster", "golven", "octopus", "rodepepers"],
19 "verhaal" : ["valleien", "ijs", "verlangens", "panter", "maan", "stormen"],
21 # genre = style.keys()
28 for mystyle
in style
[mygenre
]:
30 os
.mkdir(mygenre
+ "/" + mystyle
)
36 os
.mkdir(mygenre
+ "/" + mystyle
+ "/" + myspice
)
40 def make_frame(odt
, graphic_style
, h
, w
, ax
, ay
, z
):
41 odt
.styles
.addElement(graphic_style
)
42 myframe
= Frame(stylename
=graphic_style
, height
=h
, width
=w
,
45 myframe
.addElement(mytextbox
)
46 return {"frame" : myframe
, "textbox" : mytextbox
}
48 def kinda_p(paragraphic_style
, text
, textbox
):
49 p
= P(stylename
=paragraphic_style
, text
=text
)
52 def frame_border(odt
):
54 graphic_style
= Style(name
="Border Frame", family
="graphic")
55 graphic_properties
= GraphicProperties(border
="0.5mm double #000000")
56 graphic_style
.addElement(graphic_properties
)
57 frame
= make_frame(odt
, graphic_style
, "273mm", "194mm", "-12mm", "-12mm", "1")
58 frameframe
= frame
["frame"]
59 textbox
= frame
["textbox"]
62 paragraphic_style
= Style(name
="Frame Border is Empty", family
="paragraph")
63 text_props
= TextProperties()
64 paragraphic_style
.addElement(text_props
)
65 paragraph_props
= ParagraphProperties()
66 paragraphic_style
.addElement(paragraph_props
)
67 odt
.styles
.addElement(paragraphic_style
)
68 kinda_p(paragraphic_style
, u
"", textbox
)
70 odt
.text
.addElement(frameframe
)
75 header_graphic_style
= Style(name
="Header Frame", family
="graphic")
76 header_graphic_properties
= GraphicProperties(backgroundcolor
="#ffffff", border
="10mm double #ffffff")
77 header_graphic_style
.addElement(header_graphic_properties
)
78 frame
= make_frame(odt
, header_graphic_style
, "20mm", "170mm", "0mm", "0mm", "2")
79 frameframe
= frame
["frame"]
80 textbox
= frame
["textbox"]
83 header_paragraphic_style
= Style(name
="Header - Date", family
="paragraph")
84 atlas_paragraphic_style
= Style(name
="Header - Atlas", family
="paragraph")
86 header_text_props
= TextProperties(fontsize
="12pt", fontfamily
="DIN_OSP")
87 atlas_text_props
= TextProperties(fontsize
="16pt", fontfamily
="OSP-Atlast")
89 header_paragraphic_style
.addElement(header_text_props
)
90 atlas_paragraphic_style
.addElement(atlas_text_props
)
92 header_paragraph_props
= ParagraphProperties(textalign
="right")
93 atlas_paragraph_props
= ParagraphProperties(textalign
="right")
94 header_paragraphic_style
.addElement(header_paragraph_props
)
95 atlas_paragraphic_style
.addElement(atlas_paragraph_props
)
96 odt
.styles
.addElement(header_paragraphic_style
)
97 odt
.styles
.addElement(atlas_paragraphic_style
)
99 kinda_p(header_paragraphic_style
, u
"Gaasbeek, 13 februari 2050", textbox
)
101 kinda_p(atlas_paragraphic_style
, u
"Hello World", textbox
)
103 odt
.text
.addElement(frameframe
)
106 def __init__(self
, genre
, style
):
110 def read_stylesheet(self
):
111 myname
= self
.genre
+ "_" + self
.style
112 # find text_template and paragraph_template dicts in stylesheet
113 text_template
[self
.genre
].update(text_style
[self
.genre
][self
.style
])
114 paragraph_template
[self
.genre
].update(paragraph_style
[self
.genre
][self
.style
])
115 oostyle
= Style(name
="Body Text", family
="paragraph")
116 oostyle
.addElement(TextProperties(attributes
=text_template
[self
.genre
]))
117 oostyle
.addElement(ParagraphProperties(attributes
=paragraph_template
[self
.genre
]))
120 def text_frame(self
, odt
):
121 ### header frame (for letter)
122 if self
.genre
== "brief":
126 graphic_style
= Style(name
="Main Body Frame", family
="graphic")
127 graphic_properties
= GraphicProperties(backgroundcolor
="#ffffff", border
="10mm double #ffffff")
128 graphic_style
.addElement(graphic_properties
)
129 frame
= make_frame(odt
, graphic_style
, "240mm", "170mm", "0mm", "0mm", "1")
130 frameframe
= frame
["frame"]
131 textbox
= frame
["textbox"]
133 for paragraph
in txt
[self
.genre
]:
134 kinda_p("Body Text", paragraph
, textbox
)
136 odt
.text
.addElement(frameframe
)
138 def label(self
, odt
, spice
):
140 graphic_style
= Style(name
="Label Frame", family
="graphic")
141 graphic_properties
= GraphicProperties()
142 graphic_style
.addElement(graphic_properties
)
143 frame
= make_frame(odt
, graphic_style
, "5mm", "50mm", "60mm", "263mm", "1")
144 frameframe
= frame
["frame"]
145 textbox
= frame
["textbox"]
148 paragraphic_style
= Style(name
="Label Text", family
="paragraph")
149 text_props
= TextProperties(fontsize
="11.1pt", fontfamily
="Nimbus Sans L", color
="#ffffff")
150 paragraphic_style
.addElement(text_props
)
151 paragraph_props
= ParagraphProperties(backgroundcolor
="#000000", textalign
="center")
152 paragraphic_style
.addElement(paragraph_props
)
153 odt
.styles
.addElement(paragraphic_style
)
154 kinda_p(paragraphic_style
, spice
+ " " + self
.style
, textbox
)
156 odt
.text
.addElement(frameframe
)