How to use the ase.gui.ui.Button 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 / movie.py View on Github external
def __init__(self, gui):
        self.win = win = ui.Window(_('Movie'), self.close)
        win.add(_('Image number:'))
        self.frame_number = ui.Scale(gui.frame + 1, 1,
                                     len(gui.images),
                                     callback=self.new_frame)
        win.add(self.frame_number)

        win.add([ui.Button(_('First'), self.click, -1, True),
                 ui.Button(_('Back'), self.click, -1),
                 ui.Button(_('Forward'), self.click, 1),
                 ui.Button(_('Last'), self.click, 1, True)])

        play = ui.Button(_('Play'), self.play)
        stop = ui.Button(_('Stop'), self.stop)

        # TRANSLATORS: This function plays an animation forwards and backwards
        # alternatingly, e.g. for displaying vibrational movement
        self.rock = ui.CheckButton(_('Rock'))

        win.add([play, stop, self.rock])

        if len(gui.images) > 150:
            skipdefault = len(gui.images) // 150
            tdefault = min(max(len(gui.images) / (skipdefault * 5.0),
github rosswhitfield / ase / ase / gui / constraints.py View on Github external
def __init__(self, gui):
        win = ui.Window(_('Constraints'))
        win.add([ui.Button(_('Constrain'), self.selected),
                 _('selected atoms')])
        win.add([ui.Button(_('Constrain'), self.immobile),
                 _('immobile atoms')])
        win.add([ui.Button(_('Unconstrain'), self.unconstrain),
                 _('selected atoms')])
        win.add(ui.Button(_('Clear constraints'), self.clear))
        self.gui = gui
github rosswhitfield / ase / ase / gui / constraints.py View on Github external
def __init__(self, gui):
        win = ui.Window(_('Constraints'))
        win.add([ui.Button(_('Constrain'), self.selected),
                 _('selected atoms')])
        win.add([ui.Button(_('Constrain'), self.immobile),
                 _('immobile atoms')])
        win.add([ui.Button(_('Unconstrain'), self.unconstrain),
                 _('selected atoms')])
        win.add(ui.Button(_('Clear constraints'), self.clear))
        self.gui = gui
github rosswhitfield / ase / ase / gui / calculator.py View on Github external
def __init__(self, index):
        ui.Button.__init__(self, 'Delete')
        alignment = self.get_children()[0]
        hbox = alignment.get_children()[0]
        #self.set_size_request(1, 3)
        image, label = hbox.get_children()
        if image is not None:
            label.set_text('Del')
        self.index = index
github rosswhitfield / ase / ase / gui / calculator.py View on Github external
pack(vbox, ui.Label(""))
        pack(vbox, [ui.Label(_("Epsilon (eV):"))])
        tbl, self.epsilon_adj = self.makematrix(self.present)
        pack(vbox, [tbl])
        pack(vbox, ui.Label(""))
        pack(vbox, [ui.Label(_(u"Sigma (Å):"))])
        tbl, self.sigma_adj = self.makematrix(self.present)
        pack(vbox, [tbl])
        # TRANSLATORS: Shift roughly means adjust (about a potential)
        self.modif = ui.CheckButton(_("Shift to make smooth at cutoff"))
        self.modif.set_active(True)
        pack(vbox, ui.Label(""))
        pack(vbox, self.modif)
        pack(vbox, ui.Label(""))
        butbox = ui.HButtonBox()
        cancel_but = ui.Button('Cancel')
        cancel_but.connect('clicked', lambda widget: self.destroy())
        ok_but = ui.Button('OK')
        ok_but.connect('clicked', self.ok)
        butbox.pack_start(cancel_but, 0, 0)
        butbox.pack_start(ok_but, 0, 0)
        butbox.show_all()
        pack(vbox, [butbox], end=True, bottom=True)
        vbox.show()
        self.add(vbox)

        # Now, set the parameters
        if param and param['elements'] == self.present:
            self.set_param(self.epsilon_adj, param["epsilon"], nelem)
            self.set_param(self.sigma_adj, param["sigma"], nelem)
            self.modif.set_active(param["modified"])
github rosswhitfield / ase / ase / gui / calculator.py View on Github external
# run command and location of POTCAR files:
        pack(vbox, ui.Label(_('VASP execution command: ')))
        self.run_command = pack(vbox, ui.Entry(max=0))
        if 'VASP_COMMAND' in os.environ:
            self.run_command.set_text(os.environ['VASP_COMMAND'])
        pack(vbox, ui.Label(_('Directory for species defaults: ')))
        self.pp_path = pack(vbox, ui.Entry(max=0))
        if 'VASP_PP_PATH' in os.environ:
            self.pp_path.set_text(os.environ['VASP_PP_PATH'])

        # Buttons at the bottom
        pack(vbox, ui.Label(""))
        butbox = ui.HButtonBox()
        set_default_but = ui.Button(_("Set Defaults"))
        set_default_but.connect("clicked", self.set_defaults)
        import_vasp_but = ui.Button(_("Import VASP files"))
        import_vasp_but.connect("clicked", self.import_vasp_files)
        export_vasp_but = ui.Button(_("Export VASP files"))
        export_vasp_but.connect("clicked", self.export_vasp_files)
        cancel_but = ui.Button('Cancel')
        cancel_but.connect('clicked', lambda widget: self.destroy())
        ok_but = ui.Button('OK')
        ok_but.connect('clicked', self.ok)
        butbox.pack_start(set_default_but, 0, 0)
        butbox.pack_start(import_vasp_but, 0, 0)
        butbox.pack_start(export_vasp_but, 0, 0)
        butbox.pack_start(cancel_but, 0, 0)
        butbox.pack_start(ok_but, 0, 0)
        butbox.show_all()
        pack(vbox, [butbox], end=True, bottom=True)
        vbox.show()
        self.add(vbox)
github rosswhitfield / ase / ase / gui / calculator.py View on Github external
tbl, self.epsilon_adj = self.makematrix(self.present)
        pack(vbox, [tbl])
        pack(vbox, ui.Label(""))
        pack(vbox, [ui.Label(_(u"Sigma (Å):"))])
        tbl, self.sigma_adj = self.makematrix(self.present)
        pack(vbox, [tbl])
        # TRANSLATORS: Shift roughly means adjust (about a potential)
        self.modif = ui.CheckButton(_("Shift to make smooth at cutoff"))
        self.modif.set_active(True)
        pack(vbox, ui.Label(""))
        pack(vbox, self.modif)
        pack(vbox, ui.Label(""))
        butbox = ui.HButtonBox()
        cancel_but = ui.Button('Cancel')
        cancel_but.connect('clicked', lambda widget: self.destroy())
        ok_but = ui.Button('OK')
        ok_but.connect('clicked', self.ok)
        butbox.pack_start(cancel_but, 0, 0)
        butbox.pack_start(ok_but, 0, 0)
        butbox.show_all()
        pack(vbox, [butbox], end=True, bottom=True)
        vbox.show()
        self.add(vbox)

        # Now, set the parameters
        if param and param['elements'] == self.present:
            self.set_param(self.epsilon_adj, param["epsilon"], nelem)
            self.set_param(self.sigma_adj, param["sigma"], nelem)
            self.modif.set_active(param["modified"])

        self.show()
        self.grab_add()  # Lock all other windows
github rosswhitfield / ase / ase / gui / repeat.py View on Github external
def __init__(self, gui):
        win = ui.Window(_('Repeat'))
        win.add(_('Repeat atoms:'))
        self.repeat = [ui.SpinBox(r, 1, 9, 1, self.change)
                       for r in gui.images.repeat]
        win.add(self.repeat)
        win.add(ui.Button(_('Set unit cell'), self.set_unit_cell))

        for sb, vec in zip(self.repeat, gui.atoms.cell):
            if not vec.any():
                sb.active = False

        self.gui = gui
github rosswhitfield / ase / ase / gui / surfaceslab.py View on Github external
def __init__(self, gui):
        self.element = Element('', self.apply)
        self.structure = ui.ComboBox(structures, structures,
                                     self.structure_changed)
        self.structure_warn = ui.Label('', 'red')
        self.orthogonal = ui.CheckButton('', True, self.make)
        self.lattice_a = ui.SpinBox(3.2, 0.0, 10.0, 0.001, self.make)
        self.retrieve = ui.Button(_('Get from database'),
                                  self.structure_changed)
        self.lattice_c = ui.SpinBox(None, 0.0, 10.0, 0.001, self.make)
        self.x = ui.SpinBox(1, 1, 30, 1, self.make)
        self.x_warn = ui.Label('', 'red')
        self.y = ui.SpinBox(1, 1, 30, 1, self.make)
        self.y_warn = ui.Label('', 'red')
        self.z = ui.SpinBox(1, 1, 30, 1, self.make)
        self.vacuum_check = ui.CheckButton('', False, self.vacuum_checked)
        self.vacuum = ui.SpinBox(5, 0, 40, 0.01, self.make)
        self.description = ui.Label('')

        win = self.win = ui.Window(_('Surface'))
        win.add(ui.Text(introtext))
        win.add(self.element)
        win.add([_('Structure:'), self.structure, self.structure_warn])
        win.add([_('Orthogonal cell:'), self.orthogonal])
github rosswhitfield / ase / ase / gui / calculator.py View on Github external
self.pack_line(vbox, self.gpaw_radio, self.gpaw_setup, self.gpaw_info)

        # FHI-aims
        self.aims_radio = ui.RadioButton(self.none_radio,
                                         _("Density Functional Theory "
                                           "(FHI-aims)"))
        self.aims_setup = ui.Button(_("Setup"))
        self.aims_info = InfoButton(aims_info_txt)
        self.aims_setup.connect("clicked", self.aims_setup_window)
        self.pack_line(vbox, self.aims_radio, self.aims_setup, self.aims_info)

        # VASP
        self.vasp_radio = ui.RadioButton(self.none_radio,
                                         _("Density Functional Theory "
                                           "(VASP)"))
        self.vasp_setup = ui.Button(_("Setup"))
        self.vasp_info = InfoButton(vasp_info_txt)
        self.vasp_setup.connect("clicked", self.vasp_setup_window)
        self.pack_line(vbox, self.vasp_radio, self.vasp_setup, self.vasp_info)

        # Buttons etc.
        pack(vbox, ui.Label(""))
        buts = cancel_apply_ok(
            cancel=lambda widget: self.destroy(), apply=self.apply, ok=self.ok)
        pack(vbox, [buts], end=True, bottom=True)
        self.check = ui.CheckButton(
            _("Check that the calculator is "
              "reasonable."))
        self.check.set_active(True)
        fr = ui.Frame()
        fr.add(self.check)
        fr.show_all()