Пример #1
0
 def image(self,
           src,
           link=None,
           name="Cover",
           align="left",
           width="100%",
           height="80%"):
     self.deprecatedPrint()
     if src is None:
         return None
     elems_img = [
         attributes.Src(f"{src}?naas_uid={str(uuid.uuid4())}"),
         attributes.Height(height),
         attributes.Width(width),
         {
             "name": "border",
             "value": 0
         },
         attributes.InlineStyle(
             border_radius="4px",
             margin=self.__align(align),
             display="block",
         ),
         {
             "name": "alt",
             "value": name
         },
     ]
     if link:
         return tags.A(attributes.Href(link), tags.Img(elems_img))
     else:
         return tags.Img(elems_img)
Пример #2
0
 def button(
     self,
     link,
     text="Open",
     width="auto",
     color="white",
     background_color="black",
 ):
     self.deprecatedPrint()
     return tags.Center(
         tags.Div(
             attributes.InlineStyle(margin="48px 0"),
             tags.A(
                 attributes.Class("button"),
                 attributes.Href(link),
                 attributes.InlineStyle(
                     background_color=background_color,
                     color=color,
                     border_radius="4px",
                     display="inline-block",
                     font_family="sans-serif",
                     font_size="18px",
                     font_weight="bold",
                     line_height="60px",
                     text_align="center",
                     text_decoration="none",
                     width=width,
                     max_width="300px",
                     padding_left="10px",
                     padding_right="10px",
                     _webkit_text_size_adjust="none",
                 ),
                 tags.Text(text),
             ),
         ))
Пример #3
0
 def link(self, link, title="Open", color="#B200FD"):
     self.deprecatedPrint()
     return tags.A(
         attributes.Href(link),
         attributes.InlineStyle(color=color, text_decoration="underline"),
         tags.Text(title),
     )
Пример #4
0
 def button(self, text, link, color="#ffffff", background_color="#B200FD"):
     return tags.Center(
         tags.Div(
             attributes.InlineStyle(margin="48px 0"),
             tags.A(
                 attributes.Class("button"),
                 attributes.Href(link),
                 attributes.InlineStyle(
                     background_color=background_color,
                     color=color,
                     border_radius="4px",
                     display="inline-block",
                     font_family="sans-serif",
                     font_size="18px",
                     font_weight="bold",
                     line_height="60px",
                     text_align="center",
                     text_decoration="none",
                     width="300px",
                     _webkit_text_size_adjust="none",
                 ),
                 tags.Text(text),
             ),
         )
     )
Пример #5
0
 def table(self, data, border=True):
     self.deprecatedPrint()
     elems = []
     table_arr = None
     row_link = False
     row_link_index = -1
     if isinstance(data, pd.DataFrame):
         table_arr = list(data.values.tolist())
         row_link = True if "row_link" in data.columns else False
         try:
             row_link_index = list(data.columns).index("row_link")
         except ValueError:
             pass
     elif isinstance(data, list):
         table_arr = data
     else:
         error_text = f"Table should be array, not {data.__name__}"
         self.print_error(error_text)
         return None
     for row in table_arr:
         res = []
         if isinstance(row, list):
             for i in range(len(row)):
                 cell = row[i]
                 if isinstance(data, pd.DataFrame):
                     col = list(data.columns)[i]
                     if row_link:
                         if col != "row_link":
                             link = row[row_link_index]
                             res.append(
                                 tags.Td(
                                     tags.A(
                                         attributes.Href(link),
                                         self.__convert(cell, col),
                                     )))
                     else:
                         res.append(tags.Td(self.__convert(cell, col)))
                 else:
                     res.append(
                         tags.Td(
                             tags.Text(cell) if isinstance(cell, str
                                                           ) else cell))
         else:
             res.append(
                 tags.Td(tags.Text(row) if isinstance(row, str) else row))
         elems.append(tags.Tr(res))
     tab = tags.Table(
         attributes.InlineStyle(width="100%"),
         attributes.Class("table_border") if border else None,
         elems,
     )
     return tags.P(tab)
Пример #6
0
    def logo(self, src, link=None, name="Logo"):

        if src is None:
            return None
        elems_img = [
            attributes.Src(f"{src}?naas_uid={str(uuid.uuid4())}"),
            attributes.Height(80),
            attributes.Width(80),
            {"name": "alt", "value": name},
        ]
        if link:
            return tags.A(attributes.Href(link), tags.Center(tags.Img(elems_img)))
        else:
            return tags.Center(tags.Img(elems_img))
Пример #7
0
 def cover(self, src, link=None, name="Cover"):
     if src is None:
         return None
     elems_img = [
         attributes.Src(f"{src}?naas_uid={str(uuid.uuid4())}"),
         attributes.Height(80),
         attributes.Width(600),
         {"name": "border", "value": 0},
         attributes.InlineStyle(
             border_radius="4px",
             display="block",
             max_width="100%",
             min_width="100px",
             width="100%",
         ),
         {"name": "alt", "value": name},
     ]
     if link:
         return tags.A(attributes.Href(link), tags.Img(elems_img))
     else:
         return tags.Img(elems_img)
Пример #8
0
 def link(self, link, title):
     return tags.A(
         attributes.Href(link),
         attributes.InlineStyle(color="#B200FD", text_decoration="underline"),
         tags.Text(title),
     )