datastack
- class datastack.stacker.stacker.datastack(type='main_page', path='', title='', main=False)
Bases:
objectDatastack class for holding all widgets
- Parameters:
type (str main_page | sidebar | container | column | tab | None) –
path (str) – Path for pages
title (str) – Title of container or tabs
main (bool) – True value idenfify the class instance as main class where as false value identify as subclass
- append_block(block, location='main_page')
- build_app()
- build_element_from_blocks(blocks)
- button(name: str, on_click: callable | None = None, args: Tuple | None = None, id: str | None = None)
Button widget.
- Parameters:
name (str) – A name of button, clerly explain the purpouse of button to user.
on_click (callable) – callable function to invoke when button is clicked
args (tuple) – An optional tuple of args to pass to the callback.
Examples
Simple button
>>> ds.button('Click')
Button on_click
>>> def click(): ... ds.write('button clicked') >>> ds.button('Click', on_click=click)
- cache_data(func: callable)
Decorator to cache functions that return data
- Parameters:
func (callable) – the function to cache
- chart(data, on_click: callable | None = None, id: str | None = None)
Display plotly chart
- Parameters:
data (plotly data) – plotly fig object to display chart
id (str) – An optional string or integer to use as the unique key for the element.
- chart_builder(id='')
- clear_notifications()
Clear all notifications
- code(data: str, id: str | None = None)
Dispay code element
- Parameters:
data (str) – Code as string to display
id (str) – An optional string or integer to use as the unique key for the element.
- columns(col_number: int, id: str | None = None)
Insert containers laid out as side-by-side columns
- Parameters:
col_number (int) – number of columns required
id (str) – An optional string or integer to use as the unique key for the element.
- container()
Insert a multi-element container.
- dataframe(data, id: str | None = None)
Display dataframe
- Parameters:
data (pandas.DataFrame) – The data to display
id (str) – An optional string or integer to use as the unique key for the element.
- date_input(label: str = None, value: str = None, min: str = '1970-01-01', max: str = '2500-01-01', date_format: str = 'yyyy-MM-dd', use_container_width: bool = False, disabled: bool = False, id: str | None = None, on_change: callable | None = None)
Display a date input element.
- Parameters:
label (str) – A short label explaining to the user what this date input is for.
value (str) – The value of this widget when it first renders (ex.: 2023-01-01).
min (str) – The minimum selectable date (ex.: 2023-01-01).
max (str) – The maximum selectable date (ex.: 2023-01-01).
date_format (str) – To set the date format (ex.: dd-MMM-yyyy).
use_container_width (bool) – An optional boolean, which makes the date picker stretch its width to match the parent container.
disabled (bool) – An optional boolean, which disables the date input if set to True. The default is False.
id (str) – An optional string or integer to use as the unique key for the element.
on_change (callable) – An option callback invoked when this text input’s value chnages.
- divider()
A divider line separates different content.
- dump_app()
- dynamic_widget_id()
- editable_html(key, id='')
- error(text: str = None, id: str | None = None)
Display an error message.
- Parameters:
text (str) – The info text to display
id (str) – An optional string or integer to use as the unique key for the element.
- expander(name: str)
A content area which can be collapsed and expanded.
Paramters
- namestr
name of the expander
- gat_all_blocks()
- get_all_dfs()
- get_app_block_by_id(id)
- get_block_by_id(id)
- header(data, id: str | None = None)
Display text in header formatting.
- Parameters:
data (str) – The text to display
id (str) – An optional string or integer to use as the unique key for the element.
- html(html: str, id: str | None = None)
Diapy html element
- Parameters:
html (str) – html string
id (str) – An optional string or integer to use as the unique key for the element.
- iframe(url: str, id: str | None)
Display iframe element
- Parameters:
url (str) – url for iframe
- image(data, id: str | None = None)
Diaplay an image
- Parameters:
data (ImageFile) – image data to diaplay
id (str) – An optional string or integer to use as the unique key for the element.
- info(text: str = None, id: str | None = None)
Display an informational message.
- Parameters:
text (str) – The info text to display
id (str) – An optional string or integer to use as the unique key for the element.
- input(label: str, value: str | None = '', id: str | None = None, on_change: callable | None = '', args: Tuple | None = None)
Display a single-line text input widget
- Parameters:
label (str) – A short label explaining to the user what this input is for.
value (str or None) – The text value of this element when it first renders.
id (str) – An optional string or integer to use as the unique key for the element.
on_change (callable) – An option callback invoked when this text input’s value chnages.
args (dict) – An optional tuple of args to pass to the callback
- list(data: Iterable = [], on_click: Callable | None = None, id: str | None = None, slot_start: str | None = None, slot_end: str | None = None)
Display list element
- Parameters:
data (Iterable) – Iterable list to display
on_click (Callable) – An option callback invoked when this list is clicked.
id (str) – An optional string or integer to use as the unique key for the element.
slot_start (str) – data top be diplay at the beginning of the list
slot_end (str) – data to be dipalay at the end of the list
- markdown(data: str, id: str | None = None)
Diaply markdown text
- Parameters:
data (str) – data to diaply
id (str) – An optional string or integer to use as the unique key for the element.
Display menu
- Parameters:
data (Iterable) – data to be displayed in the menu.
value (str or None) – The text value of this element when it first renders.
id (str) – An optional string or integer to use as the unique key for the element.
on_change (callable) – An option callback invoked when this text input’s value chnages.
- notification(data: str)
Diaplay a short message
- Parameters:
data (str) – The string to display
- page(path: str)
create a new page
- Parameters:
path (str) – Path of page
- page_link(page_name, id='')
- pyplot(fig)
Display a matplotlib.pyplot figure.
- Parameters:
fig (Matplotlib Figure) – The figure to plot.
- query(data, id='')
- radio_button(label: str, options: Iterable = [], value: str | None = '', id: str | None = None, on_change: callable | None = '', args: Tuple | None = None)
Display a radio button element
- Parameters:
label (str) – A short label explaining to the user what this input is for.
options (Itrerable) – Options for select element.
value (str or None) – The text value of this element when it first renders.
id (str) – An optional string or integer to use as the unique key for the element.
on_change (callable) – An option callback invoked when this text input’s value chnages.
args (dict) – An optional tuple of args to pass to the callback
- replace_block(id, new_block)
- rerun(my_vars={}, old_app='')
- select(label: str, options: Iterable = [], value: str | None = '', id: str | None = None, on_change: callable | None = '', args: Tuple | None = None)
Select component to select value from options
Paramaters
- labelstr
A short label explaining to the user what this input is for.
- optionsItrerable
Options for select element.
- valuestr or None
The text value of this element when it first renders.
- idstr
An optional string or integer to use as the unique key for the element.
- on_changecallable
An option callback invoked when this text input’s value chnages.
- argsdict
An optional tuple of args to pass to the callback
- set_page(page_name)
- sidebar()
Sidebar
- slider(min: int, max: int, value: int, id: str | None = None, on_change: callable | None = None)
Display a slider element.
- Parameters:
min (int) – minimum value of slider
max (int) – maximum value of slider
value (str or None) – The text value of this element when it first renders.
id (str) – An optional string or integer to use as the unique key for the element.
on_change (callable) – An option callback invoked when this text input’s value chnages.
- sql_connection(params)
- subheader(data, id: str | None = None)
Display text in subheader formatting.
- Parameters:
data (str) – The text to display
id (str) – An optional string or integer to use as the unique key for the element.
- success(text: str = None, id: str | None = None)
Display an informational message.
- Parameters:
text (str) – The success text to display
id (str) – An optional string or integer to use as the unique key for the element.
- table(data, column_definition: dict = {}, id: str | None = None)
Display a dataframe as an interactive table.
- Parameters:
data (pandas.DataFrame) – The data to display.
column_defination (dict) – define columns
id (str) – An optional string or integer to use as the unique key for the element.
- tabs(tab_list: Iterable, id: str | None = None)
Insert containers separated into tabs.
- Parameters:
tab_list (iterable) – list of tabs to diaplay
id (str) – An optional string or integer to use as the unique key for the element.
- update_app_state(key, value)
- update_state()
- warning(text: str = None, id: str | None = None)
Display an warning message.
- Parameters:
text (str) – The info text to display
id (str) – An optional string or integer to use as the unique key for the element.
- write(data, id: str | None = None)
Write text to the app.
- Parameters:
data (str) – text to display
id (str) – An optional string or integer to use as the unique key for the element.
Example
Basic use case
>>> ds.write('Hello, World!')