Esempio n. 1
0
def layout(*args):

    style = """
    <style>
      # MainMenu {visibility: hidden;}
      footer {visibility: hidden;}
     .stApp { bottom: 105px; }
    </style>
    """

    style_div = styles(position="fixed",
                       left=0,
                       bottom=0,
                       margin=px(0, 0, 0, 0),
                       width=percent(100),
                       color="black",
                       text_align="center",
                       height="auto",
                       opacity=1)

    style_hr = styles(display="block",
                      margin=px(8, 8, "auto", "auto"),
                      border_style="inset",
                      border_width=px(2))

    body = p()
    foot = div(style=style_div)(hr(style=style_hr), body)

    st.markdown(style, unsafe_allow_html=True)

    for arg in args:
        if isinstance(arg, str):
            body(arg)

        elif isinstance(arg, HtmlElement):
            body(arg)

    st.markdown(str(foot), unsafe_allow_html=True)


# def footer():
#     myargs = [
#         "Made in ",
#         image('https://avatars3.githubusercontent.com/u/45109972?s=400&v=4',
#               width=px(25), height=px(25)),
#         " with ❤️ by Avinash Nair",
#         link("https://www.linkedin.com/in/avinash-nair-299b72157/", "@AvinashNair"),
#         br(),

#     ]
#     layout(*myargs)

# if __name__ == "__main__":
#     footer()
Esempio n. 2
0
def layout(*args):

    style = """
    <style>
      # MainMenu {visibility: hidden;}
      footer {visibility: hidden;}
     .stApp { bottom: 63px; }
    </style>
    """

    style_div = styles(
        position="fixed",
        left=0,
        bottom=0,
        margin=px(0,0,0,0),
        width=percent(100),
        height="auto",
        color="black", 
        background_color="#f5f7f8",
        text_align="left",
        opacity=1
    )

    style_hr = styles(
        position="fixed",
        left=0,
        bottom=px(75),
        display="block",
        margin=px(8, 8, "auto", "auto"),
        border_style="inset",
        border_width=px(2)
    )

    body = p()
    foot = div(
        style=style_div
    )(
        #hr(
        #    style=style_hr
        #),
        body
    )

    st.markdown(style, unsafe_allow_html=True)

    for arg in args:
        if isinstance(arg, str):
            body(arg)

        elif isinstance(arg, HtmlElement):
            body(arg)

    st.markdown(str(foot), unsafe_allow_html=True)
Esempio n. 3
0
def footer():
    myargs = [
        "Designed in ",
        link('https://streamlit.io/',
            image('https://avatars3.githubusercontent.com/u/45109972?s=400&v=4',
                  width=px(25), height=px(25))),
        " by Carlos Espejo Peña",
        br(),
        link("https://www.linkedin.com/in/carlosespejopena/", image('https://drive.google.com/uc?export=view&id=1nx0u9GeUyYttqyju6Z1824UCqto6hXZv')),
        " | ",
        link("https://github.com/caresppen", image('https://drive.google.com/uc?export=view&id=17_77FAziJKdyZaRkjzlGFTKaPAKGdszl')),
    ]
    layout(*myargs)
Esempio n. 4
0
def footer():
    myargs = [
        "&nbsp&nbsp Coded in ",
        link("https://www.streamlit.io/", image('https://avatars3.githubusercontent.com/u/45109972?s=400&v=4',
              width=px(25), height=px(25))),
        " by ",
        link("https://www.linkedin.com/in/poleniuk/", "@PatrykOleniuk"),
        br(),"&nbsp&nbsp",
        link("https://www.buymeacoffee.com/patrykoleniuk", 
            image('https://camo.githubusercontent.com/b18e4e33eb88215c17a5a66de3b51d92ce22cd7bbaf568561ecb0154ef3c1d76/68747470733a2f2f63646e2d696d616765732d312e6d656469756d2e636f6d2f6d61782f3733382f312a47393575796f6b4148344a433550707678344c6d6f514032782e706e67', 
            height=px(20))),
    ]
    layout(*myargs)
Esempio n. 5
0
def footer():
    myargs = [
        "Made in ",
        image('https://avatars3.githubusercontent.com/u/45109972?s=400&v=4',
              width=px(25),
              height=px(25)), " for ",
        image(
            'https://upload.wikimedia.org/wikipedia/commons/0/05/BBVA_2019.svg',
            width=px(35),
            height=px(30)), " by ",
        link('https://bluetab.com/', 'Bluetab'),
        br()
    ]
    layout(*myargs)
Esempio n. 6
0
def layout(*args):

    style = """
    <style>
      # MainMenu {visibility: hidden;}
      footer {visibility: hidden;}
     .stApp {bottom: 80px;}
    </style>
    """

    style_div = styles(
        position="fixed",
        left=0,
        bottom=0,
        margin=px(0, 0, 0, 0),
        width=percent(100),
        color="#2E5987",
        text_align="center",
        height="auto",
        opacity=1
    )

    style_hr = styles(
        display="block",
        margin=px(-70, 0, 10, 0),
        border_style="inset",
        border_width=px(1)
    )

    body = p()
    foot = div(
        style=style_div
    )(
        hr(
            style=style_hr
        ),
        body
    )

    st.markdown(style, unsafe_allow_html=True)

    for arg in args:
        if isinstance(arg, str):
            body(arg)

        elif isinstance(arg, HtmlElement):
            body(arg)

    st.markdown(str(foot), unsafe_allow_html=True)
Esempio n. 7
0
def footer():
    myargs = [
        "Made in 	&nbsp; ",
        image('https://avatars3.githubusercontent.com/u/45109972?s=400&v=4',
              width=px(25),
              height=px(25)),
        "	&nbsp; with ❤️ by &nbsp;",
        link("https://twitter.com/ChristianKlose3", "@ChristianKlose3"),
        br(),
        link(
            "https://www.buymeacoffee.com/ChrisChross",
            image('https://i.imgur.com/thJhzOO.png'),
        ),
    ]
    layout(*myargs)
Esempio n. 8
0
def footer():
    myargs = [
        "Our analysis was conducted based on market prices as at December 2019, prior to the outbreak of COVID-19.",
        br(),
        "Made in ",
        image(
            'https://seeklogo.com/images/U/united-kingdom-flag-logo-1088704B5E-seeklogo.com.png',
            width=px(20),
            height=px(15)),
        " by Pierre, Harry & Ian",
        # link("https://twitter.com/ChristianKlose3", "Pierre, Harry & Ian"),
        # br(),with ❤️
        # link("https://buymeacoffee.com/chrischross", image('https://i.imgur.com/thJhzOO.png')),
    ]
    layout(*myargs)
def annotated_text(*args, **kwargs):
    """Writes test with annotations into your Streamlit app.
    Parameters
    ----------
    *args : str, tuple or htbuilder.HtmlElement
        Arguments can be:
        - strings, to draw the string as-is on the screen.
        - tuples of the form (main_text, annotation_text, background, color) where
          background and foreground colors are optional and should be an CSS-valid string such as
          "#aabbcc" or "rgb(10, 20, 30)"
        - HtmlElement objects in case you want to customize the annotations further. In particular,
          you can import the `annotation()` function from this module to easily produce annotations
          whose CSS you can customize via keyword arguments.
    """
    out = div(style=styles(
        font_family="sans-serif",
        line_height="1.5",
        color="white",
        font_size=px(16),
    ))

    for arg in args:
        if isinstance(arg, str):
            out(arg)

        elif isinstance(arg, HtmlElement):
            out(arg)

        elif isinstance(arg, tuple):
            out(annotation(*arg))

        else:
            raise Exception("Oh noes!")

    streamlit.components.v1.html(str(out), **kwargs)
Esempio n. 10
0
def layout(*args):
    style = """
    <style>
        MainMenu {visibility: hidden;}
        footer {visibility: hidden;}
        .stApp { bottom: 60px; }
    </style>
    """

    style_div = styles(
        position="fixed",
        left=0,
        bottom=0,
        margin=px(0, 15, 0, 0),
        text_align="center",
        opacity=0.5,
    )

    body = p()
    foot = div(style=style_div)(body)

    st.markdown(style, unsafe_allow_html=True)
    for arg in args:
        if isinstance(arg, str):
            body(arg)
        elif isinstance(arg, HtmlElement):
            body(arg)
    st.markdown(str(foot), unsafe_allow_html=True)
Esempio n. 11
0
def layout(*args):

    style = """
    <style>
      # MainMenu {visibility: hidden;}
      footer {visibility: hidden;}
     .stApp { bottom: 70px; }
    </style>
    """

    style_div = styles(
        position="fixed",
        left=0,
        bottom=0,
        margin=px(0, 0, 0, 0),
        width=percent(100),
        color="green",
        text_align="center",
        height="auto",
        opacity=1,
    )
    body = p()
    foot = div(style=style_div)(body)

    for arg in args:
        if isinstance(arg, str):
            body(arg)

        elif isinstance(arg, HtmlElement):
            body(arg)

    st.markdown(str(foot), unsafe_allow_html=True)
Esempio n. 12
0
def annotated_text(
    df,
    text_column="text",
    value_column="vals",
    cmap_name="Blues",
    scale_values=True,
    **kwargs
):
    """Writes test with annotations into your Streamlit app.

    Parameters
    ----------

    *df : pandas DataFrame
    """

    style = styles(font_family="sans-serif", line_height="1.5", font_size=px(32),)

    out = div(_class="", style=style)
    cmap = get_cmap(cmap_name)

    for text, val in zip(df[text_column], df[value_column]):

        if scale_values:
            val = (val + 0.25) ** 2.5

        color = (np.array(cmap(val)[:3]) * 255).astype(np.uint8)
        contrast = contrastColor(*color)

        hex_color = "#%02x%02x%02x" % (color[0], color[1], color[2])
        contrast_color = "#%02x%02x%02x" % (contrast[0], contrast[1], contrast[2])

        out(annotation(body=text + " ", color=contrast_color, background=hex_color))

    streamlit.components.v1.html(str(out), **kwargs)
Esempio n. 13
0
def footer():
    myargs = [
        image('https://avatars3.githubusercontent.com/u/45109972?s=400&v=4',
              width=px(25),
              height=px(25)),
        " Developed",
        " by ",
        link("https://www.github.com/chunmusic", "ChunzPs "),
        image('https://avatars3.githubusercontent.com/u/45109972?s=400&v=4',
              width=px(25),
              height=px(25)),
        br(),
        br(),
        link("https://www.buymeacoffee.com/ChunzPs",
             image('https://i.imgur.com/thJhzOO.png')),
    ]
    layout(*myargs)
Esempio n. 14
0
def footer():
    myargs = [
        "&nbsp&nbsp Coded in ",
        link(
            "https://www.streamlit.io/",
            image(
                'https://avatars3.githubusercontent.com/u/45109972?s=400&v=4',
                width=px(25),
                height=px(25))),
        " by ",
        link("https://www.linkedin.com/in/poleniuk/", "@PatrykOleniuk"),
        br(),
        "&nbsp &nbsp",
        link("https://github.com/patryk-oleniuk/face-emotionz-webapp",
             "source code"),
    ]
    layout(*myargs)
def annotated_text(*args):
    """Writes test with annotations into your Streamlit app.

    Parameters
    ----------
    *args : str, tuple or htbuilder.HtmlElement
        Arguments can be:
        - strings, to draw the string as-is on the screen.
        - tuples of the form (main_text, annotation_text, background, color) where
          background and foreground colors are optional and should be an CSS-valid string such as
          "#aabbcc" or "rgb(10, 20, 30)"
        - HtmlElement objects in case you want to customize the annotations further. In particular,
          you can import the `annotation()` function from this module to easily produce annotations
          whose CSS you can customize via keyword arguments.

    Examples
    --------

    >>> annotated_text(
    ...     "This ",
    ...     ("is", "verb", "#8ef"),
    ...     " some ",
    ...     ("annotated", "adj", "#faa"),
    ...     ("text", "noun", "#afa"),
    ...     " for those of ",
    ...     ("you", "pronoun", "#fea"),
    ...     " who ",
    ...     ("like", "verb", "#8ef"),
    ...     " this sort of ",
    ...     ("thing", "noun", "#afa"),
    ... )

    >>> annotated_text(
    ...     "Hello ",
    ...     annotation("world!", "noun", color="#8ef", border="1px dashed red"),
    ... )

    """
    out = div(style=styles(
        font_family="sans-serif",
        line_height="1.5",
        font_size=px(16),
    ))

    for arg in args:
        if isinstance(arg, str):
            out(arg)

        elif isinstance(arg, HtmlElement):
            out(arg)

        elif isinstance(arg, tuple):
            out(annotation(*arg))

        else:
            raise Exception("Oh noes!")

    streamlit.components.v1.html(str(out))
def annotation(body, label="", background="#ddd", color="#333", **style):
    """Build an HtmlElement span object with the given body and annotation label.

    The end result will look something like this:

        [body | label]

    Parameters
    ----------
    body : string
        The string to put in the "body" part of the annotation.
    label : string
        The string to put in the "label" part of the annotation.
    background : string
        The color to use for the background "chip" containing this annotation.
    color : string
        The color to use for the body and label text.
    **style : dict
        Any CSS you want to use to customize the containing "chip".

    Examples
    --------

    Produce a simple annotation with default colors:

    >>> annotation("apple", "fruit")

    Produce an annotation with custom colors:

    >>> annotation("apple", "fruit", background="#FF0", color="black")

    Produce an annotation with crazy CSS:

    >>> annotation("apple", "fruit", background="#FF0", border="1px dashed red")

    """

    if "font_family" not in style:
        style["font_family"] = "sans-serif"

    return span(style=styles(
        background=background,
        border_radius=rem(0.33),
        color=color,
        padding=(rem(0.17), rem(0.67)),
        display="inline-flex",
        justify_content="center",
        align_items="center",
        **style,
    ))(body,
       span(style=styles(
           color=color,
           font_size=em(0.67),
           opacity=0.5,
           padding_left=rem(0.5),
           text_transform="uppercase",
           margin_bottom=px(-2),
       ))(label))
Esempio n. 17
0
def footer():
    myargs = [
        "&nbsp&nbsp Coded by ",
        link("https://www.grantthornton.es/", "Grant Thornton Spain"),
        br(),
        "&nbsp&nbsp",
        link(
            "https://www.buymeacoffee.com/nonay",
            image(
                'https://camo.githubusercontent.com/b18e4e33eb88215c17a5a66de3b51d92ce22cd7bbaf568561ecb0154ef3c1d76/68747470733a2f2f63646e2d696d616765732d312e6d656469756d2e636f6d2f6d61782f3733382f312a47393575796f6b4148344a433550707678344c6d6f514032782e706e67',
                height=px(20))),
    ]
    layout(*myargs)
Esempio n. 18
0
def annotate(body, label="", background="#ddd", color="#333", **style):
    if "font_family" not in style:
        style["font_family"] = "sans-serif"

    return span(style=styles(
        background=background,
        border_radius=rem(0.33),
        color=color,
        padding=(rem(0.17), rem(0.67)),
        display="inline",
        justify_content="center",
        align_items="center",
        **style,
    ))(body,
       span(style=styles(
           color=color,
           font_size=em(0.67),
           opacity=0.5,
           padding_left=rem(0.5),
           text_transform="uppercase",
           margin_bottom=px(-2),
       ))(label))
Esempio n. 19
0
    def _get_underline_element(self, token, slot_to_spans):
        if not slot_to_spans:
            return token
        max_slot_index = max(slot_to_spans.keys())
        element = token
        for slot_index in range(max_slot_index + 1):
            spans = slot_to_spans[slot_index]
            if not spans:
                color = "rgba(0, 0, 0, 0)"  # Transparent element w/opacity=0
                props = {}
            else:
                containing_slot = spans[0]
                color = containing_slot[3]
                classes = ["underline"]
                if token != SPACE:
                    classes.append("token-underline")
                classes.extend([f"span-{span[4]}" for span in spans])  # Encode ids in class names
                props = {
                    "class": " ".join(classes),
                    "data-primary-color": color
                }
            if slot_index == 0:
                padding_bottom = 0
            else:
                padding_bottom = self.underline_spacing
            display = "inline-block"
            element = htbuilder.span(
                style=styles(
                    display=display,
                    border_bottom=f"{self.underline_thickness}px solid",
                    border_color=color,
                    padding_bottom=px(padding_bottom),
                ),
                **props
            )(element)

            # Return outermost nested span
        return element
Esempio n. 20
0
    kw = keywords(text, ratio=keyword_ratio, words=keyword_word_count, split=keyword_split_output, scores=keyword_scores, pos_filter=('NN', 'JJ'), lemmatize=keyword_lemmatize, deacc=keyword_deacc)

    if kw:
        result_col.header("Keywords")
        kw_expander = result_col.beta_expander("Expand keywords!")
        if kw_expander:
            kw_expander.write(HTML_WRAPPER.format(kw), unsafe_allow_html=True)

if show_offsets:
    st.header("Offsets View")
    input_offset_col, result_offset_col = st.beta_columns(2)

    summary_out = div(style=styles(
        font_family="sans-serif",
        line_height="1.5",
        font_size=px(16),
    ))

    summaries = []
    if isinstance(summary, list):
        summaries = summary
    elif isinstance(summary, str):
        summaries = summary.split("\n")

    summary_colors = {}
    for num, summary_item in enumerate(summaries):
        color = COLORS[num%len(COLORS)]
        summary_out(annotate(summary_item, "", color))
        summary_colors[summary_item] = color

    input_out = div(style=styles(
Esempio n. 21
0
 def test_units_in_builder(self):
     dom = div(style=styles(foo=px(10, 9, 8)))
     self.assertEqual(str(dom), normalize_whitespace('''
         <div style="foo:10px 9px 8px"></div>
     '''))
Esempio n. 22
0
 def test_funcs_and_units_in_builder(self):
     dom = div(style=styles(margin=px(0, 0, 10, 0)))
     self.assertEqual(str(dom), normalize_whitespace('''
         <div style="margin:0 0 10px 0"></div>
     '''))
Esempio n. 23
0
from htbuilder import div, ul, li, img, styles, classes, fonts
from htbuilder.units import px
from htbuilder.funcs import rgba, rgb

image_paths = [
    "http://myimages.com/foo1.jpg",
    "http://myimages.com/foo2.jpg",
    "http://myimages.com/foo3.jpg",
]

html_element = div(id="container")(ul(_class="image-list")([
    li(img(src=image_path, _class="large-image")) for image_path in image_paths
]))

print(html_element)

bottom_margin = 10

s = styles(
    color="black",
    font_family=fonts("Comic Sans", "sans"),
    margin=px(0, 0, bottom_margin, 0),
    box_shadow=[
        (0, 0, px(10), rgba(0, 0, 0, 0.1)),
        (0, 0, "2px", rgb(0, 0, 0)),
    ],
)

print(s)
Esempio n. 24
0
 def test_varargs(self):
     self.assertEqual(px(10, 9, 8), ('10px', '9px', '8px'))
     self.assertEqual(px(0, 1), ('0', '1px'))
     self.assertEqual(em(5, 7), ('5em', '7em'))
     self.assertEqual(percent(99, 99.9), ('99%', '99.9%'))
Esempio n. 25
0
 def test_basic_usage(self):
     self.assertEqual(px(10), ('10px', ))
     self.assertEqual(px(0), ('0', ))
     self.assertEqual(em(5), ('5em', ))
     self.assertEqual(percent(99), ('99%', ))