UIHelper

A thin wrapper around Streamlit calls so the core logic isn’t tied directly to st.xxx calls.

Source code in LabeLMaker/utils/page_renderer.py
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
class UIHelper:
    """
    A thin wrapper around Streamlit calls so the core logic isn’t tied directly to st.xxx calls.
    """

    def __init__(self):
        self.session_state = st.session_state

    def balloons(self):
        st.balloons()

    def button(self, label, key=None):
        return st.button(label, key=key)

    def checkbox(self, label, help, key=None):
        return st.checkbox(label=label, help=help, key=key)

    def download_button(self, label, data, file_name, mime, **kwargs):
        return st.download_button(label, data, file_name, mime, **kwargs)

    def error(self, text):
        st.error(text)

    def expander(self, label, expanded=True):
        return st.expander(label, expanded=expanded)

    def file_uploader(self, label, type, accept_multiple_files, key):
        return st.file_uploader(
            label, type=type, accept_multiple_files=accept_multiple_files, key=key
        )

    def header(self, text):
        return st.header(text)

    def info(self, text):
        st.info(text)

    def markdown(self, text):
        st.markdown(text)

    def multiselect(self, label, options, **kwargs):
        return st.multiselect(label, options, **kwargs)

    def number_input(self, label, **kwargs):
        return st.number_input(label, **kwargs)

    def pyplot(self, figure):
        st.pyplot(figure)

    def radio(self, label, options, **kwargs):
        return st.radio(label, options, **kwargs)

    def rerun(self):
        st.rerun(scope="app")

    def selectbox(self, label, options, **kwargs):
        return st.selectbox(label, options, **kwargs)

    def spinner(self, text):
        return st.spinner(text)

    def subheader(self, text):
        return st.subheader(text)

    def success(self, text):
        st.success(text)

    def text_input(self, label, value="", key=None):
        return st.text_input(label, value=value, key=key)

    def warning(self, text):
        st.warning(text, icon="🚨")

    def write(self, text):
        st.write(text)