add images to the HTML file Parameters: ims (str list) -- a list of image paths txts (str list) -- a list of image names shown on the website links (str list) -- a list of hyperref links; when you click an image, it will redirect you to a new page
(self, ims, txts, links, width=400)
| 46 | h3(text) |
| 47 | |
| 48 | def add_images(self, ims, txts, links, width=400): |
| 49 | """add images to the HTML file |
| 50 | |
| 51 | Parameters: |
| 52 | ims (str list) -- a list of image paths |
| 53 | txts (str list) -- a list of image names shown on the website |
| 54 | links (str list) -- a list of hyperref links; when you click an image, it will redirect you to a new page |
| 55 | """ |
| 56 | self.t = table(border=1, style="table-layout: fixed;") # Insert a table |
| 57 | self.doc.add(self.t) |
| 58 | with self.t: |
| 59 | with tr(): |
| 60 | for im, txt, link in zip(ims, txts, links): |
| 61 | with td(style="word-wrap: break-word;", halign="center", valign="top"): |
| 62 | with p(): |
| 63 | with a(href=os.path.join('images', link)): |
| 64 | img(style="width:%dpx" % width, src=os.path.join('images', im)) |
| 65 | br() |
| 66 | p(txt) |
| 67 | |
| 68 | def save(self): |
| 69 | """save the current content to the HMTL file""" |
no outgoing calls
no test coverage detected