Returns a table containing a collection of SlideWrapper flowables.
(slides, pageSize, docWidth, numCols)
| 249 | |
| 250 | |
| 251 | def makeSlideTable(slides, pageSize, docWidth, numCols): |
| 252 | """Returns a table containing a collection of SlideWrapper flowables. |
| 253 | """ |
| 254 | |
| 255 | slides = handleHiddenSlides(slides) |
| 256 | |
| 257 | # Set table style. |
| 258 | tabStyle = TableStyle( |
| 259 | [('GRID', (0,0), (-1,-1), 0.25, colors.black), |
| 260 | ('ALIGN', (0,0), (-1,-1), 'CENTRE') |
| 261 | ]) |
| 262 | |
| 263 | # Build table content. |
| 264 | width = docWidth/numCols |
| 265 | height = width * pageSize[1]/pageSize[0] |
| 266 | matrix = [] |
| 267 | row = [] |
| 268 | for slide in slides: |
| 269 | sw = SlideWrapper(width, height, slide, pageSize) |
| 270 | if (len(row)) < numCols: |
| 271 | row.append(sw) |
| 272 | else: |
| 273 | matrix.append(row) |
| 274 | row = [] |
| 275 | row.append(sw) |
| 276 | if len(row) > 0: |
| 277 | for i in range(numCols-len(row)): |
| 278 | row.append('') |
| 279 | matrix.append(row) |
| 280 | |
| 281 | # Make Table flowable. |
| 282 | t = Table(matrix, |
| 283 | [width + 5]*len(matrix[0]), |
| 284 | [height + 5]*len(matrix)) |
| 285 | t.setStyle(tabStyle) |
| 286 | |
| 287 | return t |
| 288 | |
| 289 | |
| 290 | class SlideWrapper(Flowable): |
no test coverage detected