Coverage for /builds/ase/ase/ase/gui/constraints.py: 73.68%
19 statements
« prev ^ index » next coverage.py v7.5.3, created at 2025-08-02 00:12 +0000
« prev ^ index » next coverage.py v7.5.3, created at 2025-08-02 00:12 +0000
1# fmt: off
3import ase.gui.ui as ui
4from ase.gui.i18n import _
7class Constraints:
8 def __init__(self, gui):
9 win = ui.Window(_('Constraints'), wmtype='utility')
10 win.add([ui.Button(_('Fix'), self.selected),
11 _('selected atoms')])
12 win.add([ui.Button(_('Release'), self.unconstrain),
13 _('selected atoms')])
14 win.add(ui.Button(_('Clear all constraints'), self.clear))
15 self.gui = gui
17 def selected(self):
18 self.gui.images.set_dynamic(self.gui.images.selected, False)
19 self.gui.draw()
21 def unconstrain(self):
22 self.gui.images.set_dynamic(self.gui.images.selected, True)
23 self.gui.draw()
25 def clear(self):
26 # This clears *all* constraints. But when we constrain, we
27 # only add FixAtoms....
28 for atoms in self.gui.images:
29 atoms.constraints = []
31 # Also, these methods are repeated from settings.py *grumble*
32 self.gui.draw()