How to use the ase.gui.i18n._ 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 / colors.py View on Github external
def reset(self, gui):
        """create a new color window"""
        self.win = ui.Window(_('Colors'))
        self.gui = gui
        self.win.add(ui.Label(_('Choose how the atoms are colored:')))
        values = ['jmol', 'tag', 'force', 'velocity',
                  'initial charge', 'magmom', 'neighbors']
        labels = [_('By atomic number, default "jmol" colors'),
                  _('By tag'),
                  _('By force'),
                  _('By velocity'),
                  _('By initial charge'),
                  _('By magnetic moment'),
                  _('By number of neighbors'), ]

        haveit = ['numbers', 'positions', 'forces', 'momenta',
                  'initial_charges', 'initial_magmoms']
        for key in self.gui.atoms.arrays:
            if key not in haveit:
github rosswhitfield / ase / ase / gui / render.py View on Github external
def __init__(self, gui):
        self.gui = gui
        self.win = win = ui.Window(_('Render current view in povray ... '))
        win.add(ui.Label(_("Rendering %d atoms.") % len(self.gui.atoms)))

        guiwidth, guiheight = self.get_guisize()
        self.width_widget = ui.SpinBox(guiwidth, start=1, end=9999, step=1)
        self.height_widget = ui.SpinBox(guiheight, start=1, end=9999, step=1)
        win.add([ui.Label(_('Size')), self.width_widget,
                 ui.Label('⨯'), self.height_widget])

        self.linewidth_widget = ui.SpinBox(0.07, start=0.01, end=9.99,
                                           step=0.01)
        win.add([ui.Label(_('Line width')), self.linewidth_widget,
                 ui.Label(_('Ångström'))])

        self.constraints_widget = ui.CheckButton(_("Render constraints"))
        self.cell_widget = ui.CheckButton(_("Render unit cell"), value=True)
        win.add([self.cell_widget, self.constraints_widget])

        formula = gui.atoms.get_chemical_formula(mode='hill')
        self.basename_widget = ui.Entry(width=30, value=formula,
                                        callback=self.update_outputname)
        win.add([ui.Label(_('Output basename: ')), self.basename_widget])
        self.outputname_widget = ui.Label()
        win.add([ui.Label(_('Output filename: ')), self.outputname_widget])
        self.update_outputname()

        self.texture_widget = ui.ComboBox(labels=self.texture_list,
                                          values=self.texture_list)
        win.add([ui.Label(_('Atomic texture set:')),
github rosswhitfield / ase / ase / gui / ui.py View on Github external
def helpwindow(text):
    win = Window(_('Help'))
    win.add(Text(text))
github rosswhitfield / ase / ase / gui / energyforces.py View on Github external
def __init__(self, gui):
        Simulation.__init__(self, gui)
        self.set_title(_("Potential energy and forces"))
        self.set_default_size(-1, 400)
        vbox = ui.VBox()
        self.packtext(vbox,
                      _("Calculate potential energy and the force on all "
                        "atoms"))
        self.packimageselection(vbox)
        pack(vbox, ui.Label(""))
        self.forces = ui.CheckButton(_("Write forces on the atoms"))
        self.forces.set_active(True)
        pack(vbox, [self.forces])
        pack(vbox, [ui.Label("")])
        self.makeoutputfield(vbox)
        pack(vbox, ui.Label(""))
        self.makebutbox(vbox)
        vbox.show()
        self.add(vbox)
github rosswhitfield / ase / ase / gui / calculator.py View on Github external
def gpaw_check(self):
        try:
            import gpaw
            gpaw  # silence pyflakes
        except ImportError:
            error(_("GPAW is not installed. (Failed to import gpaw)"))
            return False
        if not hasattr(self, "gpaw_parameters"):
            error(_("You must set up the GPAW parameters"))
            return False
        return True
github rosswhitfield / ase / ase / gui / gui.py View on Github external
def get_menu_data(self):
        M = ui.MenuItem
        return [
            (_('_File'),
             [M(_('_Open'), self.open, 'Ctrl+O'),
              M(_('_New'), self.new, 'Ctrl+N'),
              M(_('_Save'), self.save, 'Ctrl+S'),
              M('---'),
              M(_('_Quit'), self.exit, 'Ctrl+Q')]),

            (_('_Edit'),
             [M(_('Select _all'), self.select_all),
              M(_('_Invert selection'), self.invert_selection),
              M(_('Select _constrained atoms'), self.select_constrained_atoms),
              M(_('Select _immobile atoms'), self.select_immobile_atoms),
              # M('---'),
              # M(_('_Copy'), self.copy_atoms, 'Ctrl+C'),
              # M(_('_Paste'), self.paste_atoms, 'Ctrl+V'),
              M('---'),
              M(_('Hide selected atoms'), self.hide_selected),
              M(_('Show selected atoms'), self.show_selected),
              M('---'),
              M(_('_Modify'), self.modify_atoms, 'Ctrl+Y'),
github rosswhitfield / ase / ase / gui / nanoparticle.py View on Github external
['natoms', 'diameter'],
                self.update_gui_size)
            self.size_natoms = ui.SpinBox(100, 1, 100000, 1,
                                          self.update_size_natoms)
            self.size_diameter = ui.SpinBox(5.0, 0, 100.0, 0.1,
                                            self.update_size_diameter)
            self.round_radio = ui.RadioButtons(
                [_('above  '), _('below  '), _('closest  ')],
                ['above', 'below', 'closest'],
                callback=self.update)
            self.smaller_button = ui.Button(_('Smaller'), self.wulff_smaller)
            self.larger_button = ui.Button(_('Larger'), self.wulff_larger)
            rows.add(_('Choose size using:'))
            rows.add(self.size_radio)
            rows.add([_('atoms'), self.size_natoms,
                      _(u'ų'), self.size_diameter])
            rows.add(
                _('Rounding: If exact size is not possible, choose the size:'))
            rows.add(self.round_radio)
            rows.add([self.smaller_button, self.larger_button])
            self.update_gui_size()
        else:
            self.smaller_button = None
            self.larger_button = None
github rosswhitfield / ase / ase / gui / gui.py View on Github external
M(_('_Modify'), self.modify_atoms, 'Ctrl+Y'),
              M(_('_Add atoms'), self.add_atoms, 'Ctrl+A'),
              M(_('_Delete selected atoms'), self.delete_selected_atoms,
                'Backspace'),
              M(_('Edit _cell'), self.cell_editor, 'Ctrl+E'),
              M('---'),
              M(_('_First image'), self.step, 'Home'),
              M(_('_Previous image'), self.step, 'Page-Up'),
              M(_('_Next image'), self.step, 'Page-Down'),
              M(_('_Last image'), self.step, 'End'),
              M(_('Append image copy'), self.copy_image)]),

            (_('_View'),
             [M(_('Show _unit cell'), self.toggle_show_unit_cell, 'Ctrl+U',
                value=self.config['show_unit_cell']),
              M(_('Show _axes'), self.toggle_show_axes,
                value=self.config['show_axes']),
              M(_('Show _bonds'), self.toggle_show_bonds, 'Ctrl+B',
                value=self.config['show_bonds']),
              M(_('Show _velocities'), self.toggle_show_velocities, 'Ctrl+G',
                value=False),
              M(_('Show _forces'), self.toggle_show_forces, 'Ctrl+F',
                value=False),
              M(_('Show _Labels'), self.show_labels,
                choices=[_('_None'),
                         _('Atom _Index'),
                         _('_Magnetic Moments'),  # XXX check if exist
                         _('_Element Symbol'),
                         _('_Initial Charges'),  # XXX check if exist
                         ]),
              M('---'),
              M(_('Quick Info ...'), self.quick_info_window, 'Ctrl+I'),
github rosswhitfield / ase / ase / gui / graphene.py View on Github external
def update_element(self, *args):
        "Called when a new element may have been entered."
        # Assumes the element widget is self.element and that a label
        # for errors is self.elementinfo.  The chemical symbol is
        # placed in self.legalelement - or None if the element is
        # invalid.
        symb = []
        if self.struct.get_active() == 2:
            # Saturated nanoribbon
            elements = (self.element.get_text(), self.element2.get_text())
        else:
            elements = (self.element.get_text(), )

        for elem in elements:
            if not elem:
                self.invalid_element(_("  No element specified!"))
                return False
            try:
                z = int(elem)
            except ValueError:
                # Probably a symbol
                try:
                    z = ase.data.atomic_numbers[elem]
                except KeyError:
                    self.invalid_element()
                    return False
            try:
                symb.append(ase.data.chemical_symbols[z])
            except KeyError:
                self.invalid_element()
                return False
        self.elementinfo.set_text("")
github rosswhitfield / ase / ase / gui / calculator.py View on Github external
def lj_check(self):
        try:
            import asap3
        except ImportError:
            error(_("ASAP is not installed. (Failed to import asap3)"))
            return False
        if not hasattr(self, "lj_parameters"):
            error(_("You must set up the Lennard-Jones parameters"))
            return False
        try:
            self.atoms.set_calculator(asap3.LennardJones(**self.lj_parameters))
        except (asap3.AsapError, TypeError, ValueError) as e:
            error(
                _("Could not create useful Lennard-Jones calculator."), str(e))
            return False
        return True