File size: 774 Bytes
4eb03cf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import streamlit.components.v1 as components

# کامپوننت اختصاصی
def custom_button(text, key=None):
    components.html(
        f"""
        <!DOCTYPE html>
        <html>
        <body>
            <button id="{key}"
                    style="background-color:#28a745;color:white;border:none;
                           border-radius:8px;padding:10px 20px;font-weight:bold;
                           width:100%;cursor:pointer;"
                    onclick="sendClick()">
                {text}
            </button>
            <script>
                function sendClick() {{
                    window.parent.postMessage("{key}_clicked", "*");
                }}
            </script>
        </body>
        </html>
        """,
        height=50
    )