| | import streamlit as st |
| | import base64 |
| | from pathlib import Path |
| |
|
| |
|
| | def _img_to_base64(path: str) -> str: |
| | """λ‘컬 μ΄λ―Έμ§ νμΌμ base64 λ¬Έμμ΄λ‘ λ³ν""" |
| | with open(path, "rb") as f: |
| | return base64.b64encode(f.read()).decode() |
| |
|
| |
|
| | def show_loading( |
| | logo_path: str = "assets/team_icon.png", |
| | size: int = 120, |
| | height_vh: int = 60, |
| | speed: float = 1.2, |
| | ): |
| | """ |
| | νμ νλ λ‘λ© λ‘κ³ νμ |
| | |
| | Returns |
| | ------- |
| | placeholder : st.empty() |
| | loading.empty()λ‘ μ κ±° κ°λ₯ |
| | """ |
| |
|
| | |
| | logo_path = Path(logo_path).as_posix() |
| |
|
| | logo_base64 = _img_to_base64(logo_path) |
| |
|
| | placeholder = st.empty() |
| | placeholder.markdown( |
| | f""" |
| | <div style=" |
| | display:flex; |
| | justify-content:center; |
| | align-items:center; |
| | height:{height_vh}vh; |
| | "> |
| | <img |
| | src="data:image/png;base64,{logo_base64}" |
| | width="{size}" |
| | style="animation: spin {speed}s linear infinite;" |
| | /> |
| | </div> |
| | |
| | <style> |
| | @keyframes spin {{ |
| | from {{ transform: rotate(0deg); }} |
| | to {{ transform: rotate(360deg); }} |
| | }} |
| | </style> |
| | """, |
| | unsafe_allow_html=True, |
| | ) |
| |
|
| | return placeholder |