How to use the ase.gui.ui function in ase

To help you get started, we’ve selected a few ase examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rosswhitfield / ase / ase / gui / settings.py View on Github external
def __init__(self, gui):
        self.gui = gui
        win = ui.Window(_('Settings'))

        # Constraints
        win.add(_('Constraints:'))
        win.add([ui.Button(_('Constrain'), self.constrain_selected),
                 '/',
                 ui.Button(_('release'), self.release_selected),
                 _(' selected atoms')])
        win.add(ui.Button(_('Constrain immobile atoms'), self.immobile))
        win.add(ui.Button(_('Clear all constraints'), self.clear_constraints))

        # Visibility
        win.add(_('Visibility:'))
        win.add([ui.Button(_('Hide'), self.hide_selected),
                 '/',
                 ui.Button(_('show'), self.show_selected),
                 _(' selected atoms')])
github rosswhitfield / ase / ase / gui / minimize.py View on Github external
def make_minimize_gui(self, box):
        self.algo = ui.combo_box_new_text()
        for m in self.minimizers:
            self.algo.append_text(m)
        self.algo.set_active(0)
        self.algo.connect('changed', self.min_algo_specific)
        pack(box, [ui.Label(_("Algorithm: ")), self.algo])

        self.fmax = ui.Adjustment(0.05, 0.00, 10.0, 0.01)
        self.fmax_spin = ui.SpinButton(self.fmax, 0, 3)
        lbl = ui.Label()
        lbl.set_markup(_("Convergence criterion: F<sub>max</sub> = "))
        pack(box, [lbl, self.fmax_spin])

        self.steps = ui.Adjustment(100, 1, 1000000, 1)
        self.steps_spin = ui.SpinButton(self.steps, 0, 0)
        pack(box, [ui.Label(_("Max. number of steps: ")), self.steps_spin])
github rosswhitfield / ase / ase / gui / add.py View on Github external
def readfile(self, filename, format=None):
        if filename == self._filename:
            # We have this file already
            return self._atoms_from_file

        from ase.io import read
        try:
            atoms = read(filename)
        except Exception as err:
            ui.show_io_error(filename, err)
            atoms = None
            filename = None

        # Cache selected Atoms/filename (or None) for future calls
        self._atoms_from_file = atoms
        self._filename = filename
        return atoms
github rosswhitfield / ase / ase / gui / minimize.py View on Github external
mininame = self.minimizers[self.algo.get_active()]
        self.begin(mode="min", algo=mininame, fmax=fmax, steps=steps)
        algo = getattr(ase.optimize, mininame)
        try:
            logger_func = self.gui.simulation['progress'].get_logger_stream
        except (KeyError, AttributeError):
            logger = None
        else:
            logger = logger_func()  # Don't catch errors in the function.

        # Display status message
        self.status_label.set_text(_("Running ..."))
        self.status_label.modify_fg(ui.STATE_NORMAL,
                                    '#AA0000')
        while ui.events_pending():
            ui.main_iteration()

        self.prepare_store_atoms()
        if mininame == "MDMin":
            minimizer = algo(self.atoms, logfile=logger,
                             dt=self.mdmin_dt.value)
        else:
            minimizer = algo(self.atoms, logfile=logger)
        minimizer.attach(self.store_atoms)
        try:
            minimizer.run(fmax=fmax, steps=steps)
        except AseGuiCancelException:
            # Update display to reflect cancellation of simulation.
            self.status_label.set_text(_("Minimization CANCELLED after "
                                         "%i steps.")
                                       % (self.count_steps,))
            self.status_label.modify_fg(ui.STATE_NORMAL,
github rosswhitfield / ase / ase / gui / modify.py View on Github external
def __init__(self, gui):
        self.gui = gui
        selected = self.selection()
        if not selected.any():
            ui.error(_('No atoms selected!'))
            return

        win = ui.Window(_('Modify'))
        element = Element(callback=self.set_element)
        win.add(element)
        win.add(ui.Button(_('Change element'),
                          partial(self.set_element, element)))
        self.tag = ui.SpinBox(0, -1000, 1000, 1, self.set_tag)
        win.add([_('Tag'), self.tag])
        self.magmom = ui.SpinBox(0.0, -10, 10, 0.1, self.set_magmom)
        win.add([_('Moment'), self.magmom])

        atoms = self.gui.atoms
        Z = atoms.numbers
        if Z.ptp() == 0:
            element.Z = Z[0]

        tags = atoms.get_tags()[selected]
        if tags.ptp() == 0:
github rosswhitfield / ase / ase / gui / calculator.py View on Github external
def run(self, widget):
        dialog = ui.MessageDialog(
            flags=ui.DIALOG_MODAL,
            type=ui.MESSAGE_INFO,
            buttons=ui.BUTTONS_CLOSE)
        dialog.set_markup(self.txt)
        dialog.connect('response', lambda x, y: dialog.destroy())
        dialog.show()
github rosswhitfield / ase / ase / gui / modify.py View on Github external
def __init__(self, gui):
        self.gui = gui
        selected = self.selection()
        if not selected.any():
            ui.error(_('No atoms selected!'))
            return

        win = ui.Window(_('Modify'))
        element = Element(callback=self.set_element)
        win.add(element)
        win.add(ui.Button(_('Change element'),
                          partial(self.set_element, element)))
        self.tag = ui.SpinBox(0, -1000, 1000, 1, self.set_tag)
        win.add([_('Tag'), self.tag])
        self.magmom = ui.SpinBox(0.0, -10, 10, 0.1, self.set_magmom)
        win.add([_('Moment'), self.magmom])

        atoms = self.gui.atoms
        Z = atoms.numbers
        if Z.ptp() == 0:
            element.Z = Z[0]
github rosswhitfield / ase / ase / gui / calculator.py View on Github external
u"k-points x size:  (%.1f, %.1f, %.1f) Å")
            pack(vbox, [self.kpts_label])
            self.k_changed()
            pack(vbox, ui.Label(""))

        # Spin polarized, charge, relativity
        self.spinpol = ui.CheckButton(_("Spin / initial moment "))
        self.spinpol.connect('toggled', self.spinpol_changed)
        self.moment = ui.Adjustment(0, -100, 100, 0.1)
        self.moment_spin = ui.SpinButton(self.moment, 0, 0)
        self.moment_spin.set_digits(2)
        self.moment_spin.set_sensitive(False)
        self.charge = ui.Adjustment(0, -100, 100, 0.1)
        self.charge_spin = ui.SpinButton(self.charge, 0, 0)
        self.charge_spin.set_digits(2)
        self.relativity_type = ui.combo_box_new_text()
        for i, x in enumerate(self.aims_relativity_list):
            self.relativity_type.append_text(x)
        self.relativity_type.connect('changed', self.relativity_changed)
        self.relativity_threshold = ui.Entry(max=8)
        self.relativity_threshold.set_text('1.00e-12')
        self.relativity_threshold.set_sensitive(False)
        pack(vbox, [
            self.spinpol, self.moment_spin, ui.Label(_("   Charge")),
            self.charge_spin, ui.Label(_("   Relativity")),
            self.relativity_type, ui.Label(_(" Threshold")),
            self.relativity_threshold
        ])
        pack(vbox, ui.Label(""))

        # self-consistency criteria
        pack(vbox, [ui.Label(_("Self-consistency convergence:"))])
github rosswhitfield / ase / ase / gui / calculator.py View on Github external
def run(self, widget):
        dialog = ui.MessageDialog(
            flags=ui.DIALOG_MODAL,
            type=ui.MESSAGE_INFO,
            buttons=ui.BUTTONS_CLOSE)
        dialog.set_markup(self.txt)
        dialog.connect('response', lambda x, y: dialog.destroy())
        dialog.show()
github rosswhitfield / ase / ase / gui / gui.py View on Github external
# TRANSLATORS: Set up (i.e. build) surfaces, nanoparticles, ...
            (_('_Setup'),
             [M(_('_Surface slab'), self.surface_window, disabled=False),
              M(_('_Nanoparticle'),
                self.nanoparticle_window),
              M(_('Nano_tube'), self.nanotube_window)]),

            # (_('_Calculate'),
            # [M(_('Set _Calculator'), self.calculator_window, disabled=True),
            #  M(_('_Energy and Forces'), self.energy_window, disabled=True),
            #  M(_('Energy Minimization'), self.energy_minimize_window,
            #    disabled=True)]),

            (_('_Help'),
             [M(_('_About'), partial(ui.about, 'ASE-GUI',
                                     version=__version__,
                                     webpage='https://wiki.fysik.dtu.dk/'
                                     'ase/ase/gui/gui.html')),
              M(_('Webpage ...'), webpage)])]