Coverage for /builds/kinetik161/ase/ase/gui/repeat.py: 95.45%
22 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 Repeat:
6 def __init__(self, gui):
7 win = ui.Window(_('Repeat'), wmtype='utility')
8 win.add(_('Repeat atoms:'))
9 self.repeat = [ui.SpinBox(r, 1, 9, 1, self.change)
10 for r in gui.images.repeat]
11 win.add(self.repeat)
12 win.add(ui.Button(_('Set unit cell'), self.set_unit_cell))
14 for sb, vec in zip(self.repeat, gui.atoms.cell):
15 if not vec.any():
16 sb.active = False
18 self.gui = gui
20 def change(self):
21 repeat = [int(r.value) for r in self.repeat]
22 self.gui.images.repeat_images(repeat)
23 self.gui.set_frame()
25 def set_unit_cell(self):
26 self.gui.images.repeat_unit_cell()
27 for r in self.repeat:
28 r.value = 1
29 self.gui.set_frame()