slash.basic
This module contains the Slash basic components.
- class slash.basic.Axes(*, width=384, height=256)
Bases:
SVGFigure with x-axis and y-axis.
Example
>>> from slash.basic import Axes, Graph >>> >>> axes = Axes() >>> axes.add_plot(Graph([0, 1, 2, 3], [42, 37, 96, 51])) >>> axes.render()
- Parameters:
- add_plot(plot)
Add plot to the figure.
- set_xlim(xmin=None, xmax=None)
- set_xticks(xticks)
- set_ylim(ymin=None, ymax=None)
- set_yticks(yticks)
- class slash.basic.Bar(xs, ys, color=None, label=None, opacity=1.0, width=None)
Bases:
PlotBar plot.
- Parameters:
- plot(frame, xy_to_uv)
Construct plot elements inside frame.
- class slash.basic.Checkbox(label='', *, checked=False, disabled=False)
Bases:
Elem,SupportsOnClickCheckbox element.
- Parameters:
- class slash.basic.DataTable(keys, *, labels=None, max_rows=10)
Bases:
ElemTable for displaying rows of data.
- Parameters:
- set_data(data)
Set data for table contents.
- set_keys(keys)
Set keys for table columns.
- class slash.basic.FillBetween(xs, ys, zs=None, color=None, opacity=1.0, label=None)
Bases:
PlotFill plot.
- Parameters:
ys (Sequence[float]) – First set of y-coordinates of data points.
zs (Sequence[float] | None) – Second set of y-coordinates of data points.
color (str | None) – Color in HTML notation. If
None, one of the default colors is used.opacity (float) – Opacity value.
label (str | None) – Label to be used in the legend.
- class slash.basic.Graph(xs, ys, color=None, label=None, opacity=1.0)
Bases:
PlotGraph plot.
- Parameters:
- class slash.basic.Icon(icon)
Bases:
ElemIcon element.
- Parameters:
icon (str) – Icon type, such as
info,warning,error,debug,loading,help,refresh,moon,sun,trash,cancel,download.
- class slash.basic.Loading(description)
Bases:
objectLoading screen as asynchronous context manager.
This class can be used for instance in a handler to show a loading screen to give the user feedback about what the handler is doing.
Example
>>> from slash.basic import Loading >>> >>> async with Loading("Doing first task..") as loading: >>> # Do first task .. >>> await loading.set_description("Doing second task..") >>> # Do second task ..
- class slash.basic.Markdown(markdown)
Bases:
HTMLMarkdown element.
- Parameters:
markdown (str) – String of markdown to be formatted as HTML.
- class slash.basic.Pie(*, width=384, height=256)
Bases:
SVGPie chart element.
- render(labels, values)
Render the pie chart.
- class slash.basic.Plot(xs, ys, color=None, label=None, opacity=1.0)
Bases:
ABCAbstract class containing information for a plot in a
Axesfigure.- Parameters:
- abstractmethod plot(frame, xy_to_uv)
Construct plot elements inside frame.
- class slash.basic.Radio(label='', *, checked=False, disabled=False)
Bases:
Elem,SupportsOnClickRadio button element.
- Parameters:
- connect(other)
Connect to other radio button.
In a group of connected radio buttons, at most one can be selected at a time.
- class slash.basic.SVGElem(tag, *children, **attrs)
Bases:
ElemAnalogous to
Elemfor SVG elements.SVG elements are created with the namespace
http://www.w3.org/2000/svg.
- class slash.basic.Scatter(xs, ys, color=None, label=None, opacity=1.0)
Bases:
PlotScatter plot.
- Parameters:
- class slash.basic.Tabs(labels, *, value=None)
Bases:
Elem,SupportsOnChangeTabs element.
- Parameters:
- class slash.basic.Upload(*, text='Drop files or click to upload', multiple=False)
Bases:
ElemUpload field element.
- Parameters:
- onupload(handler)
Add event handler for upload event.
- upload(event)
Trigger upload event.
- Parameters:
event (UploadEvent) – Event instance containing upload information.
- Return type:
None
- async slash.basic.confirm(message, *, ok_text='OK', cancel_text='Cancel')
Display confirmation dialog.