예제 #1
0
    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])

        # Special stuff for MDMin
        lbl = ui.Label(_("Pseudo time step: "))
        self.mdmin_dt = ui.Adjustment(0.05, 0.0, 10.0, 0.01)
        spin = ui.SpinButton(self.mdmin_dt, 0, 3)
        self.mdmin_widgets = [lbl, spin]
        pack(box, self.mdmin_widgets)
        self.min_algo_specific()
예제 #2
0
 def packimageselection(self,
                        outerbox,
                        txt1=_(" (rerun simulation)"),
                        txt2=_(" (continue simulation)")):
     "Make the frame for selecting starting config if more than one."
     self.startframe = ui.Frame(_("Select starting configuration:"))
     pack(outerbox, [self.startframe])
     vbox = ui.VBox()
     self.startframe.add(vbox)
     vbox.show()
     self.numconfig_format = _("There are currently %i "
                               "configurations loaded.")
     self.numconfig_label = ui.Label("")
     pack(vbox, [self.numconfig_label])
     lbl = ui.Label(
         _("Choose which one to use as the "
           "initial configuration"))
     pack(vbox, [lbl])
     self.start_radio_first = ui.RadioButton(
         None,
         _("The first configuration %s.") % txt1)
     pack(vbox, [self.start_radio_first])
     self.start_radio_nth = ui.RadioButton(self.start_radio_first,
                                           _("Configuration number "))
     self.start_nth_adj = ui.Adjustment(0, 0, 1, 1)
     self.start_nth_spin = ui.SpinButton(self.start_nth_adj, 0, 0)
     self.start_nth_spin.set_sensitive(False)
     pack(vbox, [self.start_radio_nth, self.start_nth_spin])
     self.start_radio_last = ui.RadioButton(
         self.start_radio_first,
         _("The last configuration %s.") % txt2)
     self.start_radio_last.set_active(True)
     pack(vbox, self.start_radio_last)
     self.start_radio_nth.connect("toggled", self.start_radio_nth_toggled)
     self.setupimageselection()
예제 #3
0
 def material_from_selection(self, *args):
     box_selection = self.get_selection()
     selection = self.gui.images.selected.copy()
     if selection.any():
         Z = []
         for n in range(len(selection)):
             if selection[n]:
                 Z += [self.gui.atoms.Z[n]]
         name = formula(Z)
         if (box_selection == selection).all():
             name += ': ' + self.texture_selection.get_text()
         texture_button = ui.combo_box_new_text()
         for t in self.finish_list:
             texture_button.append_text(t)
         texture_button.set_active(1)
         transparency = ui.Adjustment(0, 0.0, 1.0, 0.01)
         transparency_spin = ui.SpinButton(transparency, 0, 0)
         transparency_spin.set_digits(2)
         delete_button = ui.Button('Delete')
         index = len(self.materials)
         delete_button.connect("clicked", self.delete_material,
                               {"n": index})
         self.materials += [[
             True, selection, texture_button,
             ui.Label(_("  transparency: ")), transparency_spin,
             ui.Label("   "), delete_button,
             ui.Label()
         ]]
         self.materials[-1][-1].set_markup("    " + name)
         pack(self.tbox, [
             self.materials[-1][2], self.materials[-1][3],
             self.materials[-1][4], self.materials[-1][5],
             self.materials[-1][6], self.materials[-1][7]
         ])
     else:
         error(
             _('Can not create new texture! Must have some atoms selected '
               'to create a new material!'))
예제 #4
0
 def __init__(self, gui):
     self.gui = gui
     ui.Window.__init__(self)
     self.set_title(_('Render current view in povray ... '))
     vbox = ui.VBox()
     vbox.set_border_width(5)
     self.natoms = len(self.gui.atoms)
     pack(vbox, [ui.Label(_("Rendering %d atoms.") % self.natoms)])
     self.size = [
         ui.Adjustment(self.gui.width, 1, 9999, 50),
         ui.Adjustment(self.gui.height, 1, 9999, 50)
     ]
     self.width = ui.SpinButton(self.size[0], 0, 0)
     self.height = ui.SpinButton(self.size[1], 0, 0)
     self.render_constraints = ui.CheckButton(_("Render constraints"))
     self.render_constraints.set_sensitive(
         not self.gui.images.get_dynamic(self.gui.atoms).all())
     self.render_constraints.connect("toggled", self.toggle_render_lines)
     pack(vbox, [
         ui.Label(_("Width")), self.width,
         ui.Label(_("     Height")), self.height,
         ui.Label("       "), self.render_constraints
     ])
     self.width.connect('value-changed', self.change_width, "")
     self.height.connect('value-changed', self.change_height, "")
     self.sizeratio = gui.width / float(gui.height)
     self.line_width = ui.SpinButton(ui.Adjustment(0.07, 0.01, 9.99, 0.01),
                                     0, 0)
     self.line_width.set_digits(3)
     self.render_cell = ui.CheckButton(_("Render unit cell"))
     if self.gui.ui.get_widget(
             '/MenuBar/ViewMenu/ShowUnitCell').get_active():
         self.render_cell.set_active(True)
     else:
         self.render_cell.set_active(False)
         self.render_cell.set_sensitive(False)
     self.render_cell.connect("toggled", self.toggle_render_lines)
     have_lines = (not self.gui.images.dynamic.all()
                   ) or self.render_cell.get_active()
     self.line_width.set_sensitive(have_lines)
     pack(vbox, [
         ui.Label(_("Line width")), self.line_width,
         ui.Label(_("Angstrom           ")), self.render_cell
     ])
     pack(vbox, [ui.Label("")])
     filename = gui.window.get_title()
     len_suffix = len(filename.split('.')[-1]) + 1
     if len(filename) > len_suffix:
         filename = filename[:-len_suffix]
     self.basename = ui.Entry(max=30)
     self.basename.connect("activate", self.set_outputname, "")
     self.basename.set_text(basename(filename))
     set_name = ui.Button(_("Set"))
     set_name.connect("clicked", self.set_outputname, "")
     pack(vbox, [ui.Label(_("Output basename: ")), self.basename, set_name])
     self.outputname = ui.Label("")
     pack(vbox, [ui.Label(_("               Filename: ")), self.outputname])
     pack(vbox, [ui.Label("")])
     self.tbox = ui.VBox()
     self.tbox.set_border_width(10)
     self.default_texture = ui.combo_box_new_text()
     for t in self.finish_list:
         self.default_texture.append_text(t)
     self.default_texture.set_active(1)
     self.default_transparency = ui.Adjustment(0, 0.0, 1.0, 0.01)
     self.transparency = ui.SpinButton(self.default_transparency, 0, 0)
     self.transparency.set_digits(2)
     pack(self.tbox, [
         ui.Label(_(" Default texture for atoms: ")), self.default_texture,
         ui.Label(_("    transparency: ")), self.transparency
     ])
     pack(self.tbox,
          [ui.Label(_("Define atom selection for new texture:"))])
     self.texture_selection = ui.Entry(max=50)
     self.texture_select_but = ui.Button(_("Select"))
     self.texture_selection.connect("activate", self.select_texture, "")
     self.texture_select_but.connect("clicked", self.select_texture, "")
     pack(self.tbox, [self.texture_selection, self.texture_select_but])
     self.create_texture = ui.Button(_("Create new texture from selection"))
     self.create_texture.connect("clicked", self.material_from_selection,
                                 "")
     self.selection_help_but = ui.Button(_("Help on textures"))
     self.selection_help_but.connect("clicked", self.selection_help, "")
     self.materials = []
     pack(self.tbox, [
         self.create_texture,
         ui.Label("       "), self.selection_help_but
     ])
     pack(vbox, [self.tbox])
     pack(vbox, [ui.Label("")])
     self.camera_style = ui.combo_box_new_text()
     for c in self.cameras:
         self.camera_style.append_text(c)
     self.camera_style.set_active(0)
     self.camera_distance = ui.SpinButton(
         ui.Adjustment(50.0, -99.0, 99.0, 1.0), 0, 0)
     self.camera_distance.set_digits(1)
     pack(vbox, [
         ui.Label(_("Camera type: ")), self.camera_style,
         ui.Label(_("     Camera distance")), self.camera_distance
     ])
     self.single_frame = ui.RadioButton(None, _("Render current frame"))
     self.nimages = len(self.gui.images)
     self.iframe = self.gui.frame
     self.movie = ui.RadioButton(self.single_frame,
                                 _("Render all %d frames") % self.nimages)
     self.movie.connect("toggled", self.set_movie)
     self.movie.set_sensitive(self.nimages > 1)
     self.set_outputname()
     pack(vbox, [self.single_frame, ui.Label("   "), self.movie])
     self.transparent = ui.CheckButton(_("Transparent background"))
     self.transparent.set_active(True)
     pack(vbox, [self.transparent])
     self.run_povray = ui.CheckButton(_("Run povray       "))
     self.run_povray.set_active(True)
     self.run_povray.connect("toggled", self.toggle_run_povray, "")
     self.keep_files = ui.CheckButton(_("Keep povray files       "))
     self.keep_files.set_active(False)
     self.keep_files_status = True
     self.window_open = ui.CheckButton(_("Show output window"))
     self.window_open.set_active(True)
     self.window_open_status = True
     pack(vbox, [self.run_povray, self.keep_files, self.window_open])
     pack(vbox, [ui.Label("")])
     cancel_but = ui.Button('Cancel')
     cancel_but.connect('clicked', lambda widget: self.destroy())
     ok_but = ui.Button('OK')
     ok_but.connect('clicked', self.ok)
     close_but = ui.Button('Close')
     close_but.connect('clicked', lambda widget: self.destroy())
     butbox = ui.HButtonBox()
     butbox.pack_start(cancel_but, 0, 0)
     butbox.pack_start(ok_but, 0, 0)
     butbox.pack_start(close_but, 0, 0)
     butbox.show_all()
     pack(vbox, [butbox], end=True, bottom=True)
     self.add(vbox)
     vbox.show()
     self.show()
예제 #5
0
파일: graphene.py 프로젝트: puckvg/ase-copy
    def __init__(self, gui):
        SetupWindow.__init__(self)
        self.set_title(_("Graphene"))
        vbox = ui.VBox()

        # Intoductory text
        self.packtext(vbox, introtext)

        # Choose structure
        label = ui.Label(_("Structure: "))
        self.struct = ui.combo_box_new_text()
        for s in (_("Infinite sheet"), _("Unsaturated ribbon"),
                  _("Saturated ribbon")):
            self.struct.append_text(s)
        self.struct.set_active(0)

        pack(vbox, [label, self.struct])

        # Orientation
        label = ui.Label(_("Orientation: "))
        self.orient = ui.combo_box_new_text()
        self.orient_text = []
        for s in (_("zigzag"), _("armchair")):
            self.orient.append_text(s)
            self.orient_text.append(s)
        self.orient.set_active(0)
        pack(vbox, [label, self.orient])
        pack(vbox, ui.Label(""))

        # Choose the element and bond length
        label1 = ui.Label("Element: ")
        # label.set_alignment(0.0, 0.2)
        self.element = ui.Entry(max=3)
        self.element.set_text("C")
        self.bondlength = ui.Adjustment(1.42, 0.0, 1000.0, 0.01)
        label2 = ui.Label(_("  Bond length: "))
        label3 = ui.Label(_(u"Å"))
        bond_box = ui.SpinButton(self.bondlength, 10.0, 3)
        pack(vbox, [label1, self.element, label2, bond_box, label3])

        # Choose the saturation element and bond length
        self.sat_label1 = ui.Label(_("Saturation: "))
        # label.set_alignment(0.0, 0.2)
        self.element2 = ui.Entry(max=3)
        self.element2.set_text(_("H"))
        self.bondlength2 = ui.Adjustment(1.12, 0.0, 1000.0, 0.01)
        self.sat_label2 = ui.Label(_("  Bond length: "))
        self.sat_label3 = ui.Label(_(u"Å"))
        self.bond_box = ui.SpinButton(self.bondlength2, 10.0, 3)
        pack(vbox, [
            self.sat_label1, self.element2, self.sat_label2, self.bond_box,
            self.sat_label3
        ])

        self.elementinfo = ui.Label("")
        self.elementinfo.modify_fg(ui.STATE_NORMAL, '#FF0000')
        pack(vbox, [self.elementinfo])
        pack(vbox, ui.Label(""))

        # Size
        label1 = ui.Label(_("Width: "))
        label2 = ui.Label(_("  Length: "))
        self.n = ui.Adjustment(1, 1, 100, 1)
        self.m = ui.Adjustment(1, 1, 100, 1)
        spinn = ui.SpinButton(self.n, 0, 0)
        spinm = ui.SpinButton(self.m, 0, 0)
        pack(vbox, [label1, spinn, label2, spinm])

        # Vacuum
        label1 = ui.Label(_("Vacuum: "))
        self.vacuum = ui.Adjustment(5.0, 0.0, 1000.0, 0.1)
        label2 = ui.Label(_(u"Å"))
        vac_box = ui.SpinButton(self.vacuum, 10.0, 2)
        pack(vbox, [label1, vac_box, label2])
        pack(vbox, ui.Label(""))

        self.status = ui.Label("")
        pack(vbox, [self.status])
        pack(vbox, [ui.Label("")])

        # Buttons
        buts = cancel_apply_ok(
            cancel=lambda widget: self.destroy(), apply=self.apply, ok=self.ok)
        pack(vbox, [buts], end=True, bottom=True)

        # Finalize setup
        self.makeatoms()
        self.struct.connect('changed', self.makeatoms)
        self.orient.connect('changed', self.makeatoms)
        self.element.connect('activate', self.makeatoms)
        self.bondlength.connect('value-changed', self.makeatoms)
        self.element2.connect('activate', self.makeatoms)
        self.bondlength2.connect('value-changed', self.makeatoms)
        self.n.connect('value-changed', self.makeatoms)
        self.m.connect('value-changed', self.makeatoms)
        self.vacuum.connect('value-changed', self.makeatoms)
        self.update_gui()
        self.add(vbox)
        vbox.show()
        self.show()
        self.gui = gui
예제 #6
0
파일: crystal.py 프로젝트: puckvg/ase-copy
    def __init__(self, gui):
        SetupWindow.__init__(self)
        self.set_title(_("Create Bulk Crystal by Spacegroup"))
        self.atoms = None
        vbox = ui.VBox()
        self.packtext(vbox, introtext)
        self.structinfo = ui.combo_box_new_text()
        self.structures = {}
        for c in crystal_definitions:
            self.structinfo.append_text(c[0])
            self.structures[c[0]] = c
        self.structinfo.set_active(0)
        self.structinfo.connect("changed", self.set_lattice_type)
        self.spacegroup = ui.Entry(max=14)
        self.spacegroup.set_text('P 1')
        self.elementinfo = ui.Label("")
        self.spacegroupinfo = ui.Label(_('Number: 1'))
        pack(vbox, [
            ui.Label(_("Lattice: ")), self.structinfo,
            ui.Label(_("\tSpace group: ")), self.spacegroup,
            ui.Label('  '), self.spacegroupinfo,
            ui.Label('  '), self.elementinfo
        ])
        pack(vbox, [ui.Label("")])
        self.size = [ui.Adjustment(1, 1, 100, 1) for i in range(3)]
        buttons = [ui.SpinButton(s, 0, 0) for s in self.size]
        pack(vbox, [
            ui.Label(_("Size: x: ")), buttons[0],
            ui.Label(_("  y: ")), buttons[1],
            ui.Label(_("  z: ")), buttons[2],
            ui.Label(_(" unit cells"))
        ])
        pack(vbox, [ui.Label("")])
        self.lattice_lengths = [
            ui.Adjustment(3.0, 0.0, 1000.0, 0.01) for i in range(3)
        ]
        self.lattice_angles = [
            ui.Adjustment(90.0, 0.0, 180.0, 1) for i in range(3)
        ]
        self.lattice_lbuts = [
            ui.SpinButton(self.lattice_lengths[i], 0, 0) for i in range(3)
        ]
        self.lattice_abuts = [
            ui.SpinButton(self.lattice_angles[i], 0, 0) for i in range(3)
        ]
        for i in self.lattice_lbuts:
            i.set_digits(5)
        for i in self.lattice_abuts:
            i.set_digits(3)
        self.lattice_lequals = [ui.combo_box_new_text() for i in range(3)]
        self.lattice_aequals = [ui.combo_box_new_text() for i in range(3)]
        self.lattice_lequals[0].append_text(_('free'))
        self.lattice_lequals[0].append_text(_('equals b'))
        self.lattice_lequals[0].append_text(_('equals c'))
        self.lattice_lequals[0].append_text(_('fixed'))
        self.lattice_lequals[1].append_text(_('free'))
        self.lattice_lequals[1].append_text(_('equals a'))
        self.lattice_lequals[1].append_text(_('equals c'))
        self.lattice_lequals[1].append_text(_('fixed'))
        self.lattice_lequals[2].append_text(_('free'))
        self.lattice_lequals[2].append_text(_('equals a'))
        self.lattice_lequals[2].append_text(_('equals b'))
        self.lattice_lequals[2].append_text(_('fixed'))
        self.lattice_aequals[0].append_text(_('free'))
        self.lattice_aequals[0].append_text(_('equals beta'))
        self.lattice_aequals[0].append_text(_('equals gamma'))
        self.lattice_aequals[0].append_text(_('fixed'))
        self.lattice_aequals[1].append_text(_('free'))
        self.lattice_aequals[1].append_text(_('equals alpha'))
        self.lattice_aequals[1].append_text(_('equals gamma'))
        self.lattice_aequals[1].append_text(_('fixed'))
        self.lattice_aequals[2].append_text(_('free'))
        self.lattice_aequals[2].append_text(_('equals alpha'))
        self.lattice_aequals[2].append_text(_('equals beta'))
        self.lattice_aequals[2].append_text(_('fixed'))
        for i in range(3):
            self.lattice_lequals[i].set_active(0)
            self.lattice_aequals[i].set_active(0)
        pack(vbox, [ui.Label(_('Lattice parameters'))])
        pack(vbox, [
            ui.Label(_('\t\ta:\t')), self.lattice_lbuts[0],
            ui.Label('  '), self.lattice_lequals[0],
            ui.Label(_('\talpha:\t')), self.lattice_abuts[0],
            ui.Label('  '), self.lattice_aequals[0]
        ])
        pack(vbox, [
            ui.Label(_('\t\tb:\t')), self.lattice_lbuts[1],
            ui.Label('  '), self.lattice_lequals[1],
            ui.Label(_('\tbeta:\t')), self.lattice_abuts[1],
            ui.Label('  '), self.lattice_aequals[1]
        ])
        pack(vbox, [
            ui.Label(_('\t\tc:\t')), self.lattice_lbuts[2],
            ui.Label('  '), self.lattice_lequals[2],
            ui.Label(_('\tgamma:\t')), self.lattice_abuts[2],
            ui.Label('  '), self.lattice_aequals[2]
        ])
        self.get_data = ui.Button(_("Get from database"))
        self.get_data.connect("clicked", self.get_from_database)
        self.get_data.set_sensitive(False)
        pack(vbox, [ui.Label("     "), self.get_data])
        pack(vbox, [ui.Label("")])
        pack(vbox, [ui.Label(_("Basis: "))])
        self.elements = [[
            ui.Entry(max=3),
            ui.Entry(max=8),
            ui.Entry(max=8),
            ui.Entry(max=8), True
        ]]
        self.element = self.elements[0][0]
        add_atom = ui.Button(stock='Add')
        add_atom.connect("clicked", self.add_basis_atom)
        add_atom.connect("activate", self.add_basis_atom)
        pack(vbox, [
            ui.Label(_('  Element:\t')), self.elements[0][0],
            ui.Label(_('\tx: ')), self.elements[0][1],
            ui.Label(_('  y: ')), self.elements[0][2],
            ui.Label(_('  z: ')), self.elements[0][3],
            ui.Label('\t'), add_atom
        ])
        self.vbox_basis = ui.VBox()
        swin = ui.ScrolledWindow()
        swin.set_border_width(0)
        swin.set_policy(ui.POLICY_AUTOMATIC, ui.POLICY_AUTOMATIC)
        vbox.pack_start(swin, True, True, 0)
        swin.add_with_viewport(self.vbox_basis)
        self.vbox_basis.get_parent().set_shadow_type(ui.SHADOW_NONE)
        self.vbox_basis.get_parent().set_size_request(-1, 100)
        swin.show()

        pack(self.vbox_basis, [ui.Label('')])
        pack(vbox, [self.vbox_basis])
        self.vbox_basis.show()
        pack(vbox, [ui.Label("")])
        self.status = ui.Label("")
        pack(vbox, [self.status])
        pack(vbox, [ui.Label("")])
        self.pybut = PyButton(_("Creating a crystal."))
        self.pybut.connect('clicked', self.update)

        clear = ui.Button(stock='Clear')
        clear.connect("clicked", self.clear)
        buts = cancel_apply_ok(cancel=lambda widget: self.destroy(),
                               apply=self.apply,
                               ok=self.ok)
        pack(vbox, [self.pybut, clear, buts], end=True, bottom=True)
        self.structinfo.connect("changed", self.update)
        self.spacegroup.connect("activate", self.update)
        for s in self.size:
            s.connect("value-changed", self.update)
        for el in self.elements:
            if el[-1]:
                for i in el[:-1]:
                    i.connect("activate", self.update)
                    i.connect("changed", self.update)
        for i in range(3):
            self.lattice_lbuts[i].connect("value-changed", self.update)
            self.lattice_abuts[i].connect("value-changed", self.update)
            self.lattice_lequals[i].connect("changed", self.update)
            self.lattice_aequals[i].connect("changed", self.update)
        self.clearing_in_process = False
        self.gui = gui
        self.add(vbox)
        vbox.show()
        self.show()