Skip to content

Commit 9a5ec3d

Browse files
committed
Ref manual
(cherry picked from commit 021901b)
1 parent edffae9 commit 9a5ec3d

File tree

1 file changed

+65
-65
lines changed

1 file changed

+65
-65
lines changed

taipy/event/event_processor.py

Lines changed: 65 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -254,33 +254,33 @@ def broadcast_on_event(
254254
) -> "EventProcessor":
255255
"""Register a callback to be broadcast to all states on a specific event.
256256
257-
Arguments:
258-
callback (callable): The callback to be executed for each state when the
259-
event is produced. The callback takes the state as the first argument
260-
and the event as the second argument.
261-
```python
262-
def on_event_received(state, event: Event):
263-
...
264-
```
265-
Optionally, the callback can accept extra arguments (see the `callback_args`
266-
argument).
267-
callback_args (List[AnyOf]): The extra arguments to be passed to the callback
268-
function in addition to the state and the event.
269-
entity_type (Optional[EventEntityType]): The entity type of the event.
270-
If None, the callback is registered for all entity types.
271-
entity_id (Optional[str]): The entity id of the event.
272-
If None, the callback is registered for all entities.
273-
operation (Optional[EventOperation]): The operation of the event.
274-
If None, the callback is registered for all operations.
275-
attribute_name (Optional[str]): The attribute name of an update event.
276-
If None, the callback is registered for all attribute names.
277-
filter (Optional[Callable[[Event], bool]]): A custom filter to apply to
278-
the event before triggering the callback. The filter must accept an event
279-
as the only argument and return a boolean. If the filter returns False, the
280-
callback is not triggered.
281-
Returns:
282-
EventProcessor: The current instance of the `EventProcessor` service.
283-
"""
257+
Arguments:
258+
callback (callable): The callback to be executed for each state when the
259+
event is produced. The callback takes the state as the first argument
260+
and the event as the second argument.
261+
```python
262+
def on_event_received(state, event: Event):
263+
...
264+
```
265+
Optionally, the callback can accept extra arguments (see the `callback_args`
266+
argument).
267+
callback_args (List[AnyOf]): The extra arguments to be passed to the callback
268+
function in addition to the state and the event.
269+
entity_type (Optional[EventEntityType]): The entity type of the event.
270+
If None, the callback is registered for all entity types.
271+
entity_id (Optional[str]): The entity id of the event.
272+
If None, the callback is registered for all entities.
273+
operation (Optional[EventOperation]): The operation of the event.
274+
If None, the callback is registered for all operations.
275+
attribute_name (Optional[str]): The attribute name of an update event.
276+
If None, the callback is registered for all attribute names.
277+
filter (Optional[Callable[[Event], bool]]): A custom filter to apply to
278+
the event before triggering the callback. The filter must accept an event
279+
as the only argument and return a boolean. If the filter returns False, the
280+
callback is not triggered.
281+
Returns:
282+
EventProcessor: The current instance of the `EventProcessor` service.
283+
"""
284284
return self.__on_event(
285285
callback=callback,
286286
callback_args=callback_args,
@@ -315,41 +315,41 @@ def on_scenario_created(self,
315315
) -> "EventProcessor":
316316
""" Register a callback for scenario creation events.
317317
318-
!!! example:
318+
!!! example
319319
320320
=== "A callback for all scenario creations"
321321
322-
```python
323-
import taipy as tp
324-
from taipy import Event, EventProcessor, Gui, State
322+
```python
323+
import taipy as tp
324+
from taipy import Event, EventProcessor, Gui, State
325325
326-
def print_scenario_created(event: Event, scenario: Scenario, gui: Gui):
327-
print(f"Scenario '{scenario.name}' created at '{event.creation_date}'.")
326+
def print_scenario_created(event: Event, scenario: Scenario, gui: Gui):
327+
print(f"Scenario '{scenario.name}' created at '{event.creation_date}'.")
328328
329-
if __name__ == "__main__":
330-
gui = Gui()
331-
event_processor = EventProcessor(gui)
332-
event_processor.on_scenario_created(callback=print_scenario_created)
333-
event_processor.start()
334-
...
335-
taipy.run(gui)
336-
```
329+
if __name__ == "__main__":
330+
gui = Gui()
331+
event_processor = EventProcessor(gui)
332+
event_processor.on_scenario_created(callback=print_scenario_created)
333+
event_processor.start()
334+
...
335+
taipy.run(gui)
336+
```
337337
338338
=== "One callback for a specific scenario configuration"
339339
340-
```python
341-
import taipy as tp
342-
from taipy import Event, EventProcessor, Gui
340+
```python
341+
import taipy as tp
342+
from taipy import Event, EventProcessor, Gui
343343
344-
def print_scenario_created(event: Event, scenario: Scenario, gui: Gui):
345-
print(f"Scenario '{scenario.name}' created at '{event.creation_date}'.")
344+
def print_scenario_created(event: Event, scenario: Scenario, gui: Gui):
345+
print(f"Scenario '{scenario.name}' created at '{event.creation_date}'.")
346346
347-
if __name__ == "__main__":
348-
event_processor = EventProcessor()
349-
event_processor.on_scenario_created(callback=print_scenario_created, scenario_config="my_cfg")
350-
event_processor.start()
351-
...
352-
```
347+
if __name__ == "__main__":
348+
event_processor = EventProcessor()
349+
event_processor.on_scenario_created(callback=print_scenario_created, scenario_config="my_cfg")
350+
event_processor.start()
351+
...
352+
```
353353
354354
Arguments:
355355
callback (callable):The callback to be executed when consuming the event.
@@ -384,9 +384,9 @@ def broadcast_on_scenario_created(self,
384384
) -> "EventProcessor":
385385
""" Register a callback executed for all states on scenario creation events.
386386
387-
!!! example:
387+
!!! example
388388
389-
=== "Two callbacks for all scenario creations"
389+
=== "Two callbacks for all scenario creations"
390390
391391
```python
392392
import taipy as tp
@@ -405,7 +405,7 @@ def store_latest_scenario(state: State, event: Event, scenario: Scenario):
405405
taipy.run(gui)
406406
```
407407
408-
=== "One callback for a specific scenario configuration"
408+
=== "One callback for a specific scenario configuration"
409409
410410
```python
411411
import taipy as tp
@@ -485,7 +485,7 @@ def on_scenario_deleted(self,
485485
) -> "EventProcessor":
486486
""" Register a callback for scenario deletion events.
487487
488-
!!! example:
488+
!!! example
489489
490490
```python
491491
import taipy as tp
@@ -537,7 +537,7 @@ def broadcast_on_scenario_deleted(self,
537537
) -> "EventProcessor":
538538
""" Register a callback executed for all states on scenario deletion events.
539539
540-
!!! example:
540+
!!! example
541541
542542
```python
543543
import taipy as tp
@@ -618,7 +618,7 @@ def on_datanode_written(self,
618618
The callback is triggered when a datanode is written (see methods
619619
`DataNode.write()^` or `DataNode.append()^`).
620620
621-
!!! example:
621+
!!! example
622622
623623
```python
624624
import taipy as tp
@@ -676,7 +676,7 @@ def broadcast_on_datanode_written(self,
676676
The callback is triggered when a datanode is written (see methods
677677
`DataNode.write()^` or `DataNode.append()^`).
678678
679-
!!! example:
679+
!!! example
680680
681681
```python
682682
import taipy as tp
@@ -760,7 +760,7 @@ def on_datanode_deleted(self,
760760
) -> "EventProcessor":
761761
""" Register a callback for data node deletion events.
762762
763-
!!! example:
763+
!!! example
764764
765765
```python
766766
import taipy as tp
@@ -811,7 +811,7 @@ def broadcast_on_datanode_deleted(self,
811811
) -> "EventProcessor":
812812
""" Register a callback for each state on data node deletion events.
813813
814-
!!! example:
814+
!!! example
815815
816816
```python
817817
import taipy as tp
@@ -890,7 +890,7 @@ def on_datanode_created(self,
890890
) -> "EventProcessor":
891891
""" Register a callback to be executed on data node creation event.
892892
893-
!!! example:
893+
!!! example
894894
895895
```python
896896
import taipy as tp
@@ -941,7 +941,7 @@ def broadcast_on_datanode_created(self,
941941
) -> "EventProcessor":
942942
""" Register a callback to be executed for each state on data node creation event.
943943
944-
!!! example:
944+
!!! example
945945
946946
```python
947947
import taipy as tp
@@ -1023,7 +1023,7 @@ def on_submission_finished(self,
10231023
) -> "EventProcessor":
10241024
"""Register a callback for submission finished events.
10251025
1026-
!!! example:
1026+
!!! example
10271027
10281028
```python
10291029
import taipy as tp
@@ -1079,7 +1079,7 @@ def broadcast_on_submission_finished(self,
10791079
"""Register a callback to be executed for each state on submission finished events.
10801080
10811081
!!! example
1082-
:
1082+
10831083
```python
10841084
import taipy as tp
10851085
from taipy import Event, EventProcessor, Gui, State

0 commit comments

Comments
 (0)