Coverage for /builds/kinetik161/ase/ase/gui/constraints.py: 73.68%
19 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-12-10 11:04 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2023-12-10 11:04 +0000
1import ase.gui.ui as ui
2from ase.gui.i18n import _
5class Constraints:
6 def __init__(self, gui):
7 win = ui.Window(_('Constraints'), wmtype='utility')
8 win.add([ui.Button(_('Fix'), self.selected),
9 _('selected atoms')])
10 win.add([ui.Button(_('Release'), self.unconstrain),
11 _('selected atoms')])
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.draw()
19 def unconstrain(self):
20 self.gui.images.set_dynamic(self.gui.images.selected, True)
21 self.gui.draw()
23 def clear(self):
24 # This clears *all* constraints. But when we constrain, we
25 # only add FixAtoms....
26 for atoms in self.gui.images:
27 atoms.constraints = []
29 # Also, these methods are repeated from settings.py *grumble*
30 self.gui.draw()