@@ -254,33 +254,33 @@ def broadcast_on_event(
254
254
) -> "EventProcessor" :
255
255
"""Register a callback to be broadcast to all states on a specific event.
256
256
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
+ """
284
284
return self .__on_event (
285
285
callback = callback ,
286
286
callback_args = callback_args ,
@@ -315,41 +315,41 @@ def on_scenario_created(self,
315
315
) -> "EventProcessor" :
316
316
""" Register a callback for scenario creation events.
317
317
318
- !!! example:
318
+ !!! example
319
319
320
320
=== "A callback for all scenario creations"
321
321
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
325
325
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}'.")
328
328
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
+ ```
337
337
338
338
=== "One callback for a specific scenario configuration"
339
339
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
343
343
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}'.")
346
346
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
+ ```
353
353
354
354
Arguments:
355
355
callback (callable):The callback to be executed when consuming the event.
@@ -384,9 +384,9 @@ def broadcast_on_scenario_created(self,
384
384
) -> "EventProcessor" :
385
385
""" Register a callback executed for all states on scenario creation events.
386
386
387
- !!! example:
387
+ !!! example
388
388
389
- === "Two callbacks for all scenario creations"
389
+ === "Two callbacks for all scenario creations"
390
390
391
391
```python
392
392
import taipy as tp
@@ -405,7 +405,7 @@ def store_latest_scenario(state: State, event: Event, scenario: Scenario):
405
405
taipy.run(gui)
406
406
```
407
407
408
- === "One callback for a specific scenario configuration"
408
+ === "One callback for a specific scenario configuration"
409
409
410
410
```python
411
411
import taipy as tp
@@ -485,7 +485,7 @@ def on_scenario_deleted(self,
485
485
) -> "EventProcessor" :
486
486
""" Register a callback for scenario deletion events.
487
487
488
- !!! example:
488
+ !!! example
489
489
490
490
```python
491
491
import taipy as tp
@@ -537,7 +537,7 @@ def broadcast_on_scenario_deleted(self,
537
537
) -> "EventProcessor" :
538
538
""" Register a callback executed for all states on scenario deletion events.
539
539
540
- !!! example:
540
+ !!! example
541
541
542
542
```python
543
543
import taipy as tp
@@ -618,7 +618,7 @@ def on_datanode_written(self,
618
618
The callback is triggered when a datanode is written (see methods
619
619
`DataNode.write()^` or `DataNode.append()^`).
620
620
621
- !!! example:
621
+ !!! example
622
622
623
623
```python
624
624
import taipy as tp
@@ -676,7 +676,7 @@ def broadcast_on_datanode_written(self,
676
676
The callback is triggered when a datanode is written (see methods
677
677
`DataNode.write()^` or `DataNode.append()^`).
678
678
679
- !!! example:
679
+ !!! example
680
680
681
681
```python
682
682
import taipy as tp
@@ -760,7 +760,7 @@ def on_datanode_deleted(self,
760
760
) -> "EventProcessor" :
761
761
""" Register a callback for data node deletion events.
762
762
763
- !!! example:
763
+ !!! example
764
764
765
765
```python
766
766
import taipy as tp
@@ -811,7 +811,7 @@ def broadcast_on_datanode_deleted(self,
811
811
) -> "EventProcessor" :
812
812
""" Register a callback for each state on data node deletion events.
813
813
814
- !!! example:
814
+ !!! example
815
815
816
816
```python
817
817
import taipy as tp
@@ -890,7 +890,7 @@ def on_datanode_created(self,
890
890
) -> "EventProcessor" :
891
891
""" Register a callback to be executed on data node creation event.
892
892
893
- !!! example:
893
+ !!! example
894
894
895
895
```python
896
896
import taipy as tp
@@ -941,7 +941,7 @@ def broadcast_on_datanode_created(self,
941
941
) -> "EventProcessor" :
942
942
""" Register a callback to be executed for each state on data node creation event.
943
943
944
- !!! example:
944
+ !!! example
945
945
946
946
```python
947
947
import taipy as tp
@@ -1023,7 +1023,7 @@ def on_submission_finished(self,
1023
1023
) -> "EventProcessor" :
1024
1024
"""Register a callback for submission finished events.
1025
1025
1026
- !!! example:
1026
+ !!! example
1027
1027
1028
1028
```python
1029
1029
import taipy as tp
@@ -1079,7 +1079,7 @@ def broadcast_on_submission_finished(self,
1079
1079
"""Register a callback to be executed for each state on submission finished events.
1080
1080
1081
1081
!!! example
1082
- :
1082
+
1083
1083
```python
1084
1084
import taipy as tp
1085
1085
from taipy import Event, EventProcessor, Gui, State
0 commit comments