hyperspy.events module
- class hyperspy.events.EventSuppressor(*to_suppress)
Bases:
object
Object to enforce a variety of suppression types simultaneously
Targets to be suppressed can be added by the function add(), or given in the constructor. Valid targets are:
Event: The entire Event will be suppressed
Events: All events in th container will be suppressed
(Event, callback): The callback will be suppressed in Event
(Events, callback): The callback will be suppressed in each event in Events where it is connected.
Any iterable collection of the above target types
Example
>>> es = EventSuppressor((event1, callback1), (event1, callback2)) >>> es.add(event2, callback2) >>> es.add(event3) >>> es.add(events_container1) >>> es.add(events_container2, callback1) >>> es.add(event4, (events_container3, callback2)) >>> >>> with es.suppress(): ... do_something()
- add(*to_suppress)
Add one or more targets to be suppressed
- Valid targets are:
Event: The entire Event will be suppressed
Events: All events in the container will be suppressed
(Event, callback): The callback will be suppressed in Event
(Events, callback): The callback will be suppressed in each event in Events where it is connected.
Any iterable collection of the above target types
- suppress()
Use this function with a ‘with’ statement to temporarily suppress all events added. When the ‘with’ lock completes, the old suppression values will be restored.
See also
Events.suppress
,Event.suppress
,Event.suppress_callback
- class hyperspy.events.Events
Bases:
object
Events container.
All available events are attributes of this class.
- _update_doc()
Updates the doc to reflect the events that are contained
- suppress()
Use this function with a ‘with’ statement to temporarily suppress all callbacks of all events in the container. When the ‘with’ lock completes, the old suppression values will be restored.
Example
>>> with obj.events.suppress(): ... # Any events triggered by assignments are prevented: ... obj.val_a = a ... obj.val_b = b >>> # Trigger one event instead: >>> obj.events.values_changed.trigger()
See also
Event.suppress
,Event.suppress_callback