Coverage for ase / gui / constraints.py: 68.18%
22 statements
« prev ^ index » next coverage.py v7.13.3, created at 2026-02-04 10:20 +0000
« prev ^ index » next coverage.py v7.13.3, created at 2026-02-04 10:20 +0000
1import ase.gui.ui as ui
2from ase.gui.i18n import _
5class Constraints:
6 def __init__(self, gui):
7 win = ui.Window(_('Constraints'))
8 win.add([ui.Button(_('Fix'), self.selected), _('selected atoms')])
9 win.add(
10 [ui.Button(_('Release'), self.unconstrain), _('selected atoms')]
11 )
12 win.add(ui.Button(_('Clear all constraints'), self.clear))
13 self.gui = gui
15 def selected(self):
16 self.gui.images.set_dynamic(self.gui.images.selected, False)
17 self.gui.update_history()
18 self.gui.draw()
20 def unconstrain(self):
21 self.gui.images.set_dynamic(self.gui.images.selected, True)
22 self.gui.update_history()
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 = []
30 self.gui.update_history()
32 # Also, these methods are repeated from settings.py *grumble*
33 self.gui.draw()