pg.notify_on_change

Accessible via pg.notify_on_change, pg.symbolic.notify_on_change.

notify_on_change(enabled=True)[source]

Returns a context manager to enable or disable notification upon change.

notify_on_change is thread-safe and can be nested. For example, in the following code, _on_change (thus _on_bound) method of a will be triggered due to the rebind in the inner with statement, and those of b will not be triggered as the outer with statement disables the notification:

with pg.notify_on_change(False):
  with pg.notify_on_change(True):
    a.rebind(b=1)
  b.rebind(x=2)
Return type:

ContextManager[None]

Parameters:

enabled – If True, enable change notification in current scope. Otherwise, disable notification.

Returns:

A context manager for allowing/disallowing change notification in scope.