Skip to content

Instantly share code, notes, and snippets.

View CHerSun's full-sized avatar

Alexander Chernyshev CHerSun

  • Moscow
View GitHub Profile
@CHerSun
CHerSun / st_dataclass_form_demo.py
Last active August 27, 2023 11:56
Streamlit (st) dataclass form demo
from dataclasses import MISSING, dataclass, field, fields, is_dataclass
from datetime import date
from typing import Callable, TypeVar
import streamlit as st
T = TypeVar('T')
@dataclass
class Test:
@CHerSun
CHerSun / st_traps.py
Last active June 4, 2023 11:48
A module for Streamlit to set up traps, which are triggered on next script rerun (i.e. user action) if the trap wasn't reached.
""" A module for Streamlit to set up traps, which are triggered on next script rerun (i.e. user action) if the trap wasn't reached.
Purpose:
Help with session cleaning on dynamic forms. If user didn't reach it - then clear session.
"""
from collections.abc import Callable
import streamlit as st
__SESSION_STATE_DICT_KEY = "__INT_TRAPS_DICT"