A Streamlit extension for the Tiferet Framework
Project description
tiferet-streamlit
A Streamlit extension for the Tiferet Framework — build multi-page Streamlit applications with Domain-Driven Design.
Installation
pip install tiferet-streamlit
Quick Start
import streamlit as st
from tiferet_streamlit import StreamlitApp, ViewContext
class HomeView(ViewContext):
def init_state(self):
self.session.set('count', 0)
def render(self):
count = self.session.get('count')
st.title('Home')
st.write(f'Count: {count}')
if st.button('Increment'):
self.session.set('count', count + 1)
st.rerun()
app = StreamlitApp()
app.load_app_service()
app.run('my_interface', pages={'/': HomeView})
Core Concepts
ViewContext
The code-behind for a Streamlit page. Manages state via SessionCacheContext, dispatches Tiferet features via AppInterfaceContext, and defines UI through render().
init_state()— Called once on first construction. Override to set initial state.dispatch(feature_id, headers=None, **data)— Execute a Tiferet feature.render()— Override to define Streamlit widgets.__call__()— Makes the view callable forst.Pagecomposition.
ViewComponent
A lightweight, prop-driven sub-component with parent ViewContext access.
from tiferet_streamlit import ViewComponent
class Counter(ViewComponent):
def render(self, label='Count', start=0):
count = self.ctx.session.get('count') or start
st.write(f'{label}: {count}')
SessionCacheContext
Cache backed by st.session_state with namespace isolation for multi-page apps.
from tiferet_streamlit import SessionCacheContext
cache = SessionCacheContext(namespace='my_view')
cache.set('key', 'value')
cache.get('key') # 'value'
Multi-Page Applications
Use PageContext to register multiple views with routes:
app.run('my_interface', pages={
'/': HomeView,
'/about': AboutView,
'/settings': SettingsView,
})
Config-Driven Pages
Define pages as Page domain objects for YAML-driven configuration:
from tiferet_streamlit import Page
pages = [
Page(route='/', title='Home', icon='🏠',
view_module_path='app.views.home', view_class_name='HomeView'),
Page(route='/about', title='About', icon='ℹ️',
view_module_path='app.views.about', view_class_name='AboutView'),
]
app.run('my_interface', page_configs=pages)
Feature Dispatch
Views dispatch Tiferet features for backend logic:
class CalcView(ViewContext):
def render(self):
a = st.number_input('a')
b = st.number_input('b')
if st.button('Add'):
result = self.dispatch('calc.add', a=a, b=b)
st.write(f'Result: {result}')
API Reference
| Class | Module | Description |
|---|---|---|
Page |
domain.view |
Page configuration domain object |
ViewService |
interfaces.view |
Abstract service for page management |
SessionCacheContext |
contexts.session |
Session-state-backed cache with namespacing |
ViewContext |
contexts.view |
Page code-behind with lifecycle management |
ViewComponent |
contexts.view |
Prop-driven sub-component |
PageContext |
contexts.page |
Multi-page navigation manager |
StreamlitBuilder |
builders.main |
Application entry point (also aliased as StreamlitApp) |
Development
# Clone and set up
git clone https://github.com/greatstrength/tiferet-streamlit.git
cd tiferet-streamlit
python -m venv .venv
source .venv/bin/activate
pip install -e .[test]
# Run tests
pytest --verbose
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tiferet_streamlit-0.1.0.tar.gz.
File metadata
- Download URL: tiferet_streamlit-0.1.0.tar.gz
- Upload date:
- Size: 18.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0ed4b4a8ae6179653eb0d4a554efce9d61189761dce8f38b89895bd67e38af1
|
|
| MD5 |
0724ce8fe3de1f84615f9abbab3c0a9b
|
|
| BLAKE2b-256 |
348c084871cae3d2412d4a35364476acc1240824e0eaa3433707335f49bfdbc1
|
Provenance
The following attestation bundles were made for tiferet_streamlit-0.1.0.tar.gz:
Publisher:
python-publish.yml on greatstrength/tiferet-streamlit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tiferet_streamlit-0.1.0.tar.gz -
Subject digest:
f0ed4b4a8ae6179653eb0d4a554efce9d61189761dce8f38b89895bd67e38af1 - Sigstore transparency entry: 1476468131
- Sigstore integration time:
-
Permalink:
greatstrength/tiferet-streamlit@51a0681d6998dac1d32fa255a03c3b061e41f2e1 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/greatstrength
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@51a0681d6998dac1d32fa255a03c3b061e41f2e1 -
Trigger Event:
push
-
Statement type:
File details
Details for the file tiferet_streamlit-0.1.0-py3-none-any.whl.
File metadata
- Download URL: tiferet_streamlit-0.1.0-py3-none-any.whl
- Upload date:
- Size: 25.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20bd8bee4b54de50e3164f7f6e2ed424026e89d3da5d2498607fbe828fcede1a
|
|
| MD5 |
b2ba08ab3eb43f3441038217f4999baf
|
|
| BLAKE2b-256 |
4707687d0fb3b92d10f2eb6da56238229f99caa8f258d235a767119f10b167a9
|
Provenance
The following attestation bundles were made for tiferet_streamlit-0.1.0-py3-none-any.whl:
Publisher:
python-publish.yml on greatstrength/tiferet-streamlit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tiferet_streamlit-0.1.0-py3-none-any.whl -
Subject digest:
20bd8bee4b54de50e3164f7f6e2ed424026e89d3da5d2498607fbe828fcede1a - Sigstore transparency entry: 1476468283
- Sigstore integration time:
-
Permalink:
greatstrength/tiferet-streamlit@51a0681d6998dac1d32fa255a03c3b061e41f2e1 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/greatstrength
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@51a0681d6998dac1d32fa255a03c3b061e41f2e1 -
Trigger Event:
push
-
Statement type: