Ticket #684: testchanges.py

File testchanges.py, 407 bytes (added by Tom Goddard, 9 years ago)

Python code demonstrating how to detect atom changes.

Line 
1# Example of how to detect when Atom display states change.
2
3def got_changes(trigger_name, changes):
4 print ('atom change reasons', changes.atom_reasons()) # List of strings, e.g. ['display changed']
5 atoms = changes.modified_atoms() # Atoms object
6 print ('modified atoms', len(atoms))
7
8from chimerax.core.atomic import get_triggers
9t = get_triggers(session)
10t.add_handler('changes', got_changes)