slash.events

This module contains the Slash event classes.

class slash.events.ChangeEvent(target, value)

Bases: object

Event that fires when the editable content of an element is changed.

Parameters:
  • target (Elem) – Element whose content was changed.

  • value (str) – Value of the changed content.

property target: Elem

Element whose content was changed.

property value: str

Value of the changed content.

class slash.events.ClickEvent(target)

Bases: object

Event that fires when an element is clicked.

Parameters:

target (Elem) – Element that was clicked.

property target: Elem

Element that was clicked.

class slash.events.InputEvent(target, value)

Bases: object

Event that fires when the editable content of an element is updated.

Parameters:
  • target (Elem) – Element whose content was updated.

  • value (str) – Value of the updated content.

property target: Elem

Element whose content was updated.

property value: str

Value of the updated content.

class slash.events.MountEvent(target)

Bases: object

Event that fires when an element is mounted.

Parameters:

target (Elem) – Element that was mounted.

property target: Elem

Element that was mounted.

class slash.events.SupportsOnChange

Bases: object

Mix-in class for onchange support.

change(event)

Trigger change event.

Parameters:

event (ChangeEvent) – Change event instance to be passed to handlers.

Return type:

None

onchange(handler)

Add event handler for change event.

Parameters:

handler (Callable[[ChangeEvent], Any] | Callable[[], Any]) – Function to be called when a change event is fired.

Return type:

Self

property onchange_handlers: list[Callable[[ChangeEvent], Any] | Callable[[], Any]]
class slash.events.SupportsOnClick

Bases: object

Mix-in class for onclick support.

click(event)

Trigger click event.

Parameters:

event (ClickEvent) – Click event instance to be passed to handlers.

Return type:

None

onclick(handler)

Add event handler for click event.

Parameters:

handler (Callable[[ClickEvent], Any] | Callable[[], Any]) – Function to be called when a click event is fired.

Return type:

Self

property onclick_handlers: list[Callable[[ClickEvent], Any] | Callable[[], Any]]
class slash.events.SupportsOnInput

Bases: object

Mix-in class for oninput support.

input(event)

Trigger input event.

Parameters:

event (InputEvent) – Input event instance to be passed to handlers.

Return type:

None

oninput(handler)

Add event handler for input event.

Parameters:

handler (Callable[[InputEvent], Any] | Callable[[], Any]) – Function to be called when an input event is fired.

Return type:

Self

property oninput_handlers: list[Callable[[InputEvent], Any] | Callable[[], Any]]
class slash.events.UnmountEvent(target)

Bases: object

Event that fires when an element is unmounted.

Parameters:

target (Elem) – Element that was unmounted.

property target: Elem

Element that was unmounted.

class slash.events.UploadEvent(files)

Bases: object

Event that fires when one or more file are uploaded.

Parameters:

files (list[UploadedFile]) – List of uploaded files.

files: list[UploadedFile]
class slash.events.UploadedFile(name, path, size)

Bases: object

Class containing information about an uploaded file.

Parameters:
  • name (str) – Name of the uploaded file.

  • path (Path) – Path to the temporarily saved file.

  • size (int) – Size of the file in bytes.

name: str
path: Path
size: int