Esempio n. 1
0
    def __init__(self, gui):
        SetupWindow.__init__(self)
        self.set_title("Nanotube")
        vbox = gtk.VBox()

        # Intoductory text
        self.packtext(vbox, introtext)

        # Choose the element and bond length
        label1 = gtk.Label("Element: ")
        #label.set_alignment(0.0, 0.2)
        self.element = gtk.Entry(max=3)
        self.element.set_text("C")
        self.element.connect('activate', self.update_element)
        self.bondlength = gtk.Adjustment(1.42, 0.0, 1000.0, 0.01)
        label2 = gtk.Label("  Bond length: ")
        label3 = gtk.Label("Å")
        bond_box = gtk.SpinButton(self.bondlength, 10.0, 3)
        pack(vbox, [label1, self.element, label2, bond_box, label3])
        self.elementinfo = gtk.Label("")
        self.elementinfo.modify_fg(gtk.STATE_NORMAL,
                                   gtk.gdk.color_parse('#FF0000'))
        pack(vbox, [self.elementinfo])
        pack(vbox, gtk.Label(""))

        # Choose the structure.
        pack(vbox, [gtk.Label("Select roll-up vector (n,m) and tube length:")])
        label1 = gtk.Label("n: ")
        label2 = gtk.Label("  m: ")
        self.n = gtk.Adjustment(5, 1, 100, 1)
        self.m = gtk.Adjustment(5, 0, 100, 1)
        spinn = gtk.SpinButton(self.n, 0, 0)
        spinm = gtk.SpinButton(self.m, 0, 0)
        label3 = gtk.Label("  Length: ")
        self.length = gtk.Adjustment(1, 1, 100, 1)
        spinl = gtk.SpinButton(self.length, 0, 0)
        pack(vbox, [label1, spinn, label2, spinm, label3, spinl])
        self.err = gtk.Label("")
        self.err.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#FF0000'))
        pack(vbox, [self.err])
        pack(vbox, gtk.Label(""))
        self.n.connect('value-changed', self.update_n)
        self.m.connect('value-changed', self.update_m)

        # Buttons
        self.pybut = PyButton("Creating a nanoparticle.")
        self.pybut.connect('clicked', self.makeatoms)
        buts = cancel_apply_ok(cancel=lambda widget: self.destroy(),
                               apply=self.apply,
                               ok=self.ok)
        pack(vbox, [self.pybut, buts], end=True, bottom=True)

        # Finalize setup
        self.add(vbox)
        vbox.show()
        self.show()
        self.gui = gui
Esempio n. 2
0
    def __init__(self, gui):
        SetupWindow.__init__(self)
        self.set_title(_("Nanotube"))
        vbox = gtk.VBox()

        # Intoductory text
        self.packtext(vbox, introtext)
           
        # Choose the element and bond length
        label1 = gtk.Label(_("Element: "))
        #label.set_alignment(0.0, 0.2)
        self.element = gtk.Entry(max=3)
        self.element.set_text("C")
        self.element.connect('activate', self.update_element)
        self.bondlength = gtk.Adjustment(1.42, 0.0, 1000.0, 0.01)
        label2 = gtk.Label(_("  Bond length: "))
        label3 = gtk.Label(_("Å"))
        bond_box = gtk.SpinButton(self.bondlength, 10.0, 3)
        pack(vbox, [label1, self.element, label2, bond_box, label3])
        self.elementinfo = gtk.Label("")
        self.elementinfo.modify_fg(gtk.STATE_NORMAL,
                                   gtk.gdk.color_parse('#FF0000'))
        pack(vbox, [self.elementinfo])
        pack(vbox, gtk.Label(""))

        # Choose the structure.
        pack(vbox, [gtk.Label(_("Select roll-up vector (n,m) "
                                "and tube length:"))])
        label1 = gtk.Label("n: ")
        label2 = gtk.Label("  m: ")
        self.n = gtk.Adjustment(5, 1, 100, 1)
        self.m = gtk.Adjustment(5, 0, 100, 1)
        spinn = gtk.SpinButton(self.n, 0, 0)
        spinm = gtk.SpinButton(self.m, 0, 0)
        label3 = gtk.Label(_("  Length: "))
        self.length = gtk.Adjustment(1, 1, 100, 1)
        spinl = gtk.SpinButton(self.length, 0, 0)
        pack(vbox, [label1, spinn, label2, spinm, label3, spinl])
        self.err = gtk.Label("")
        self.err.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#FF0000'))
        pack(vbox, [self.err])
        pack(vbox, gtk.Label(""))

        # Buttons
        self.pybut = PyButton(_("Creating a nanoparticle."))
        self.pybut.connect('clicked', self.makeatoms)
        buts = cancel_apply_ok(cancel=lambda widget: self.destroy(),
                               apply=self.apply,
                               ok=self.ok)
        pack(vbox, [self.pybut, buts], end=True, bottom=True)

        # Finalize setup
        self.add(vbox)
        vbox.show()
        self.show()
        self.gui = gui
Esempio n. 3
0
File: colors.py Progetto: lqcata/ase
 def __init__(self, gui):
     gtk.Window.__init__(self)
     self.gui = gui
     self.colormode = gui.colormode
     self.actual_colordata = None
     self.set_title(_("Colors"))
     vbox = gtk.VBox()
     self.add(vbox)
     vbox.show()
     # The main layout consists of two columns, the leftmost split in an upper and lower part.
     self.maintable = gtk.Table(2,2)
     pack(vbox, self.maintable)
     self.methodbox = gtk.VBox()
     self.methodbox.show()
     self.maintable.attach(self.methodbox, 0, 1, 0, 1)
     self.scalebox = gtk.VBox()
     self.scalebox.show()
     self.maintable.attach(self.scalebox, 0, 1, 1, 2)
     self.colorbox = gtk.Frame()
     self.colorbox.show()
     self.maintable.attach(self.colorbox, 1, 2, 0, 2, gtk.EXPAND)
     # Upper left: Choose how the atoms are colored.
     lbl = gtk.Label(_("Choose how the atoms are colored:"))
     pack(self.methodbox, [lbl])
     self.radio_jmol = gtk.RadioButton(None, _('By atomic number, default "jmol" colors'))
     self.radio_atno = gtk.RadioButton(self.radio_jmol,
                                       _('By atomic number, user specified'))
     self.radio_tag = gtk.RadioButton(self.radio_jmol, _('By tag'))
     self.radio_force = gtk.RadioButton(self.radio_jmol, _('By force'))
     self.radio_velocity = gtk.RadioButton(self.radio_jmol, _('By velocity'))
     self.radio_manual = gtk.RadioButton(self.radio_jmol, _('Manually specified'))
     self.radio_same = gtk.RadioButton(self.radio_jmol, _('All the same color'))
     self.force_box = gtk.VBox()
     self.velocity_box = gtk.VBox()
     for widget in (self.radio_jmol, self.radio_atno, self.radio_tag,
                   self.radio_force, self.force_box, self.radio_velocity,
                   self.velocity_box, self.radio_manual, self.radio_same):
         pack(self.methodbox, [widget])
         if isinstance(widget, gtk.RadioButton):
             widget.connect('toggled', self.method_radio_changed)
     # Now fill in the box for additional information in case the force is used.
     self.force_label = gtk.Label(_("This should not be displayed!"))
     pack(self.force_box, [self.force_label])
     self.force_min = gtk.Adjustment(0.0, 0.0, 100.0, 0.05)
     self.force_max = gtk.Adjustment(0.0, 0.0, 100.0, 0.05)
     self.force_steps = gtk.Adjustment(10, 2, 500, 1)
     force_apply = gtk.Button(_('Update'))
     force_apply.connect('clicked', self.set_force_colors)
     pack(self.force_box, [gtk.Label(_('Min: ')),
                           gtk.SpinButton(self.force_min, 10.0, 2),
                           gtk.Label(_('  Max: ')),
                           gtk.SpinButton(self.force_max, 10.0, 2),
                           gtk.Label(_('  Steps: ')),
                           gtk.SpinButton(self.force_steps, 1, 0),
                           gtk.Label('  '),
                           force_apply])
     self.force_box.hide()
     # Now fill in the box for additional information in case the velocity is used.
     self.velocity_label = gtk.Label("This should not be displayed!")
     pack(self.velocity_box, [self.velocity_label])
     self.velocity_min = gtk.Adjustment(0.0, 0.0, 10.0, 0.005)
     self.velocity_max = gtk.Adjustment(0.0, 0.0, 10.0, 0.005)
     self.velocity_steps = gtk.Adjustment(10, 2, 500, 1)
     velocity_apply = gtk.Button(_('Update'))
     velocity_apply.connect('clicked', self.set_velocity_colors)
     pack(self.velocity_box, [gtk.Label(_('Min: ')),
                              gtk.SpinButton(self.velocity_min, 10.0, 3),
                              gtk.Label(_('  Max: ')),
                              gtk.SpinButton(self.velocity_max, 10.0, 3),
                              gtk.Label(_('  Steps: ')),
                              gtk.SpinButton(self.velocity_steps, 1, 0),
                              gtk.Label('  '),
                              velocity_apply])
     self.velocity_box.hide()
     # Lower left: Create a color scale
     pack(self.scalebox, gtk.Label(""))
     lbl = gtk.Label(_('Create a color scale:'))
     pack(self.scalebox, [lbl])
     color_scales = (
         _('Black - white'),
         _('Black - red - yellow - white'),
         _('Black - green - white'),
         _('Black - blue - cyan'),
         _('Hue'),
         _('Named colors')
         )
     self.scaletype_created = None
     self.scaletype = gtk.combo_box_new_text()
     for s in color_scales:
         self.scaletype.append_text(s)
     self.createscale = gtk.Button(_("Create"))
     pack(self.scalebox, [self.scaletype, self.createscale])
     self.createscale.connect('clicked', self.create_color_scale)
     # The actually colors are specified in a box possibly with scrollbars
     self.colorwin = gtk.ScrolledWindow()
     self.colorwin.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
     self.colorwin.show()
     self.colorbox.add(self.colorwin)
     self.colorwin.add_with_viewport(gtk.VBox()) # Dummy contents
     buts = cancel_apply_ok(cancel=lambda widget: self.destroy(),
                            apply=self.apply,
                            ok=self.ok)
     pack(vbox, [buts], end=True, bottom=True)
     # Make the initial setup of the colors
     self.color_errors = {}
     self.init_colors_from_gui()
     self.show()
     gui.register_vulnerable(self)
Esempio n. 4
0
    def __init__(self, gui):
        SetupWindow.__init__(self)
        self.set_title("Nanoparticle")
        self.atoms = None
        self.no_update = True

        vbox = gtk.VBox()

        # Intoductory text
        self.packtext(vbox, introtext)

        # Choose the element
        label = gtk.Label("Element: ")
        label.set_alignment(0.0, 0.2)
        element = gtk.Entry(max=3)
        self.element = element
        lattice_button = gtk.Button("Get structure")
        lattice_button.connect('clicked', self.set_structure_data)
        self.elementinfo = gtk.Label(" ")
        pack(vbox, [label, element, self.elementinfo, lattice_button],
             end=True)
        self.element.connect('activate', self.update)
        self.legal_element = False

        # The structure and lattice constant
        label = gtk.Label("Structure: ")
        self.structure = gtk.combo_box_new_text()
        self.list_of_structures = []
        self.needs_4index = {}
        self.needs_2lat = {}
        self.factory = {}
        for abbrev, name, n4, c, factory in self.structure_data:
            self.structure.append_text(name)
            self.list_of_structures.append(abbrev)
            self.needs_4index[abbrev] = n4
            self.needs_2lat[abbrev] = c
            self.factory[abbrev] = factory
        self.structure.set_active(0)
        self.fourindex = self.needs_4index[self.list_of_structures[0]]
        self.structure.connect('changed', self.update_structure)

        label2 = gtk.Label("Lattice constant:  a =")
        self.lattice_const_a = gtk.Adjustment(3.0, 0.0, 1000.0, 0.01)
        self.lattice_const_c = gtk.Adjustment(5.0, 0.0, 1000.0, 0.01)
        self.lattice_box_a = gtk.SpinButton(self.lattice_const_a, 10.0, 3)
        self.lattice_box_c = gtk.SpinButton(self.lattice_const_c, 10.0, 3)
        self.lattice_box_a.numeric = True
        self.lattice_box_c.numeric = True
        self.lattice_label_c = gtk.Label(" c =")
        pack(vbox, [label, self.structure])
        pack(vbox, [
            label2, self.lattice_box_a, self.lattice_label_c,
            self.lattice_box_c
        ])
        self.lattice_label_c.hide()
        self.lattice_box_c.hide()
        self.lattice_const_a.connect('value-changed', self.update)
        self.lattice_const_c.connect('value-changed', self.update)

        # Choose specification method
        label = gtk.Label("Method: ")
        self.method = gtk.combo_box_new_text()
        for meth in ("Layer specification", "Wulff construction"):
            self.method.append_text(meth)
        self.method.set_active(0)
        self.method.connect('changed', self.update_gui_method)
        pack(vbox, [label, self.method])
        pack(vbox, gtk.Label(""))
        self.old_structure = None

        frame = gtk.Frame()
        pack(vbox, frame)
        framebox = gtk.VBox()
        frame.add(framebox)
        framebox.show()
        self.layerlabel = gtk.Label("Missing text")  # Filled in later
        pack(framebox, [self.layerlabel])
        # This box will contain a single table that is replaced when
        # the list of directions is changed.
        self.direction_table_box = gtk.VBox()
        pack(framebox, self.direction_table_box)
        pack(self.direction_table_box, gtk.Label("Dummy placeholder object"))
        pack(framebox, gtk.Label(""))
        pack(framebox, [gtk.Label("Add new direction:")])
        self.newdir_label = []
        self.newdir_box = []
        self.newdir_index = []
        packlist = []
        for txt in ('(', ', ', ', ', ', '):
            self.newdir_label.append(gtk.Label(txt))
            adj = gtk.Adjustment(0, -100, 100, 1)
            self.newdir_box.append(gtk.SpinButton(adj, 1, 0))
            self.newdir_index.append(adj)
            packlist.append(self.newdir_label[-1])
            packlist.append(self.newdir_box[-1])
        self.newdir_layers = gtk.Adjustment(5, 0, 100, 1)
        self.newdir_layers_box = gtk.SpinButton(self.newdir_layers, 1, 0)
        self.newdir_esurf = gtk.Adjustment(1.0, 0, 1000.0, 0.1)
        self.newdir_esurf_box = gtk.SpinButton(self.newdir_esurf, 10, 3)
        addbutton = gtk.Button("Add")
        addbutton.connect('clicked', self.row_add)
        packlist.extend([
            gtk.Label("): "), self.newdir_layers_box, self.newdir_esurf_box,
            gtk.Label("  "), addbutton
        ])
        pack(framebox, packlist)
        self.defaultbutton = gtk.Button("Set all directions to default values")
        self.defaultbutton.connect('clicked', self.default_direction_table)
        self.default_direction_table()

        # Extra widgets for the Wulff construction
        self.wulffbox = gtk.VBox()
        pack(vbox, self.wulffbox)
        label = gtk.Label("Particle size: ")
        self.size_n_radio = gtk.RadioButton(None, "Number of atoms: ")
        self.size_n_radio.set_active(True)
        self.size_n_adj = gtk.Adjustment(100, 1, 100000, 1)
        self.size_n_spin = gtk.SpinButton(self.size_n_adj, 0, 0)
        self.size_dia_radio = gtk.RadioButton(self.size_n_radio, "Volume: ")
        self.size_dia_adj = gtk.Adjustment(1.0, 0, 100.0, 0.1)
        self.size_dia_spin = gtk.SpinButton(self.size_dia_adj, 10.0, 2)
        pack(self.wulffbox, [
            label, self.size_n_radio, self.size_n_spin,
            gtk.Label("   "), self.size_dia_radio, self.size_dia_spin,
            gtk.Label("ų")
        ])
        self.size_n_radio.connect("toggled", self.update_gui_size)
        self.size_dia_radio.connect("toggled", self.update_gui_size)
        self.size_n_adj.connect("value-changed", self.update_size_n)
        self.size_dia_adj.connect("value-changed", self.update_size_dia)
        label = gtk.Label(
            "Rounding: If exact size is not possible, choose the size")
        pack(self.wulffbox, [label])
        self.round_above = gtk.RadioButton(None, "above  ")
        self.round_below = gtk.RadioButton(self.round_above, "below  ")
        self.round_closest = gtk.RadioButton(self.round_above, "closest  ")
        self.round_closest.set_active(True)
        butbox = gtk.HButtonBox()
        self.smaller_button = gtk.Button("Smaller")
        self.larger_button = gtk.Button("Larger")
        self.smaller_button.connect('clicked', self.wulff_smaller)
        self.larger_button.connect('clicked', self.wulff_larger)
        pack(butbox, [self.smaller_button, self.larger_button])
        buts = [self.round_above, self.round_below, self.round_closest]
        for b in buts:
            b.connect("toggled", self.update)
        buts.append(butbox)
        pack(self.wulffbox, buts, end=True)

        # Information
        pack(vbox, gtk.Label(""))
        infobox = gtk.VBox()
        label1 = gtk.Label("Number of atoms: ")
        self.natoms_label = gtk.Label("-")
        label2 = gtk.Label("   Approx. diameter: ")
        self.dia1_label = gtk.Label("-")
        pack(infobox, [label1, self.natoms_label, label2, self.dia1_label])
        pack(infobox, gtk.Label(""))
        infoframe = gtk.Frame("Information about the created cluster:")
        infoframe.add(infobox)
        infobox.show()
        pack(vbox, infoframe)

        # Buttons
        self.pybut = PyButton("Creating a nanoparticle.")
        self.pybut.connect('clicked', self.makeatoms)
        helpbut = help(helptext)
        buts = cancel_apply_ok(cancel=lambda widget: self.destroy(),
                               apply=self.apply,
                               ok=self.ok)
        pack(vbox, [self.pybut, helpbut, buts], end=True, bottom=True)
        self.auto = gtk.CheckButton("Automatic Apply")
        fr = gtk.Frame()
        fr.add(self.auto)
        fr.show_all()
        pack(vbox, [fr], end=True, bottom=True)

        # Finalize setup
        self.update_structure()
        self.update_gui_method()
        self.add(vbox)
        vbox.show()
        self.show()
        self.gui = gui
        self.no_update = False
Esempio n. 5
0
    def __init__(self, gui):
        SetupWindow.__init__(self)
        self.set_title(_("Graphene"))
        vbox = gtk.VBox()

        # Intoductory text
        self.packtext(vbox, introtext)

        # Choose structure
        label = gtk.Label(_("Structure: "))
        self.struct = gtk.combo_box_new_text()
        for s in (_("Infinite sheet"), _("Unsaturated ribbon"),
                  _("Saturated ribbon")):
            self.struct.append_text(s)
        self.struct.set_active(0)
        self.struct.connect('changed', self.update_gui)
        pack(vbox, [label, self.struct])

        # Orientation
        label = gtk.Label(_("Orientation: "))
        self.orient = gtk.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)
        self.orient.connect('changed', self.update_gui)
        pack(vbox, [label, self.orient])
        pack(vbox, gtk.Label(""))

        # Choose the element and bond length
        label1 = gtk.Label("Element: ")
        #label.set_alignment(0.0, 0.2)
        self.element = gtk.Entry(max=3)
        self.element.set_text("C")
        self.element.connect('activate', self.update_element)
        self.bondlength = gtk.Adjustment(1.42, 0.0, 1000.0, 0.01)
        label2 = gtk.Label(_("  Bond length: "))
        label3 = gtk.Label(_("Å"))
        bond_box = gtk.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 = gtk.Label(_("Saturation: "))
        #label.set_alignment(0.0, 0.2)
        self.element2 = gtk.Entry(max=3)
        self.element2.set_text(_("H"))
        self.element2.connect('activate', self.update_element)
        self.bondlength2 = gtk.Adjustment(1.12, 0.0, 1000.0, 0.01)
        self.sat_label2 = gtk.Label(_("  Bond length: "))
        self.sat_label3 = gtk.Label(_("Å"))
        self.bond_box = gtk.SpinButton(self.bondlength2, 10.0, 3)
        pack(vbox, [
            self.sat_label1, self.element2, self.sat_label2, self.bond_box,
            self.sat_label3
        ])

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

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

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

        # Buttons
        #self.pybut = PyButton("Creating a nanoparticle.")
        #self.pybut.connect('clicked', self.makeatoms)
        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.update_gui()
        self.add(vbox)
        vbox.show()
        self.show()
        self.gui = gui
Esempio n. 6
0
    def __init__(self, gui):
        SetupWindow.__init__(self)
        self.set_title(_("Create Bulk Crystal by Spacegroup"))
        self.atoms = None
        vbox = gtk.VBox()
        self.packtext(vbox, introtext)
        self.structinfo = gtk.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 = gtk.Entry(max=14)
        self.spacegroup.set_text('P 1')
        self.elementinfo = gtk.Label("")
        self.spacegroupinfo = gtk.Label(_('Number: 1'))
        pack(vbox, [
            gtk.Label(_("Lattice: ")), self.structinfo,
            gtk.Label(_("\tSpace group: ")), self.spacegroup,
            gtk.Label('  '), self.spacegroupinfo,
            gtk.Label('  '), self.elementinfo
        ])
        pack(vbox, [gtk.Label("")])
        self.size = [gtk.Adjustment(1, 1, 100, 1) for i in range(3)]
        buttons = [gtk.SpinButton(s, 0, 0) for s in self.size]
        pack(vbox, [
            gtk.Label(_("Size: x: ")), buttons[0],
            gtk.Label(_("  y: ")), buttons[1],
            gtk.Label(_("  z: ")), buttons[2],
            gtk.Label(_(" unit cells"))
        ])
        pack(vbox, [gtk.Label("")])
        self.lattice_lengths = [
            gtk.Adjustment(3.0, 0.0, 1000.0, 0.01) for i in range(3)
        ]
        self.lattice_angles = [
            gtk.Adjustment(90.0, 0.0, 180.0, 1) for i in range(3)
        ]
        self.lattice_lbuts = [
            gtk.SpinButton(self.lattice_lengths[i], 0, 0) for i in range(3)
        ]
        self.lattice_abuts = [
            gtk.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 = [gtk.combo_box_new_text() for i in range(3)]
        self.lattice_aequals = [gtk.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, [gtk.Label(_('Lattice parameters'))])
        pack(vbox, [
            gtk.Label(_('\t\ta:\t')), self.lattice_lbuts[0],
            gtk.Label('  '), self.lattice_lequals[0],
            gtk.Label(_('\talpha:\t')), self.lattice_abuts[0],
            gtk.Label('  '), self.lattice_aequals[0]
        ])
        pack(vbox, [
            gtk.Label(_('\t\tb:\t')), self.lattice_lbuts[1],
            gtk.Label('  '), self.lattice_lequals[1],
            gtk.Label(_('\tbeta:\t')), self.lattice_abuts[1],
            gtk.Label('  '), self.lattice_aequals[1]
        ])
        pack(vbox, [
            gtk.Label(_('\t\tc:\t')), self.lattice_lbuts[2],
            gtk.Label('  '), self.lattice_lequals[2],
            gtk.Label(_('\tgamma:\t')), self.lattice_abuts[2],
            gtk.Label('  '), self.lattice_aequals[2]
        ])
        self.get_data = gtk.Button(_("Get from database"))
        self.get_data.connect("clicked", self.get_from_database)
        self.get_data.set_sensitive(False)
        pack(vbox, [gtk.Label("     "), self.get_data])
        pack(vbox, [gtk.Label("")])
        pack(vbox, [gtk.Label(_("Basis: "))])
        self.elements = [[
            gtk.Entry(max=3),
            gtk.Entry(max=8),
            gtk.Entry(max=8),
            gtk.Entry(max=8), True
        ]]
        self.element = self.elements[0][0]
        add_atom = gtk.Button(stock=gtk.STOCK_ADD)
        add_atom.connect("clicked", self.add_basis_atom)
        add_atom.connect("activate", self.add_basis_atom)
        pack(vbox, [
            gtk.Label(_('  Element:\t')), self.elements[0][0],
            gtk.Label(_('\tx: ')), self.elements[0][1],
            gtk.Label(_('  y: ')), self.elements[0][2],
            gtk.Label(_('  z: ')), self.elements[0][3],
            gtk.Label('\t'), add_atom
        ])
        self.vbox_basis = gtk.VBox()
        swin = gtk.ScrolledWindow()
        swin.set_border_width(0)
        swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        vbox.pack_start(swin, True, True, 0)
        swin.add_with_viewport(self.vbox_basis)
        self.vbox_basis.get_parent().set_shadow_type(gtk.SHADOW_NONE)
        self.vbox_basis.get_parent().set_size_request(-1, 100)
        swin.show()

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

        clear = gtk.Button(stock=gtk.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()
Esempio n. 7
0
    def __init__(self, gui):
        SetupWindow.__init__(self)
        self.set_title(_('Surface'))
        self.atoms = None

        vbox = gtk.VBox()

        # Intoductory text
        self.packtext(vbox, introtext)
             
        # Choose the element
        label = gtk.Label(_('Element: '))
        element = gtk.Entry(max=3)
        self.element = element
        self.elementinfo = gtk.Label('')
        pack(vbox, [label, element, self.elementinfo])
        self.element.connect('activate', self.update)
        self.legal_element = False
        
        # Choose the surface structure
        label = gtk.Label(_('Structure: '))
        self.structchoice = gtk.combo_box_new_text()
        self.surfinfo = {}
        for s in surfaces:
            assert len(s) == 5
            self.structchoice.append_text(s[0])
            self.surfinfo[s[0]] = s
        pack(vbox, [label, self.structchoice])
        self.structchoice.connect('changed', self.update)

        # Choose the lattice constant
        tbl = gtk.Table(2, 3)
        label = gtk.Label(_('Lattice constant: '))
        tbl.attach(label, 0, 1, 0, 1)
        vbox2 = gtk.VBox()          # For the non-HCP stuff
        self.vbox_hcp = gtk.VBox()  # For the HCP stuff.
        self.lattice_const = gtk.Adjustment(3.0, 0.0, 1000.0, 0.01)
        lattice_box = gtk.SpinButton(self.lattice_const, 10.0, 3)
        lattice_box.numeric = True
        pack(vbox2, [gtk.Label(_('a:')), lattice_box, gtk.Label(_(u'Å'))])
        tbl.attach(vbox2, 1, 2, 0, 1)
        lattice_button = gtk.Button(_('Get from database'))
        tbl.attach(lattice_button, 2, 3, 0, 1)
        # HCP stuff
        self.hcp_ideal = (8 / 3)**(1 / 3)
        self.lattice_const_c = gtk.Adjustment(self.lattice_const.value *
                                              self.hcp_ideal,
                                              0.0, 1000.0, 0.01)
        lattice_box_c = gtk.SpinButton(self.lattice_const_c, 10.0, 3)
        lattice_box_c.numeric = True
        pack(self.vbox_hcp, [gtk.Label('c:'),
                             lattice_box_c, gtk.Label(u'Å')])
        self.hcp_c_over_a_format = 'c/a: %.3f ' + _('(%.1f %% of ideal)')
        self.hcp_c_over_a_label = gtk.Label(self.hcp_c_over_a_format %
                                            (self.hcp_ideal, 100.0))
        pack(self.vbox_hcp, [self.hcp_c_over_a_label])
        tbl.attach(self.vbox_hcp, 1, 2, 1, 2)
        tbl.show_all()
        pack(vbox, [tbl])
        self.lattice_const.connect('value-changed', self.update)
        self.lattice_const_c.connect('value-changed', self.update)
        lattice_button.connect('clicked', self.get_lattice_const)
        pack(vbox, gtk.Label(''))

        # System size
        self.size = [gtk.Adjustment(1, 1, 100, 1) for i in range(3)]
        buttons = [gtk.SpinButton(s, 0, 0) for s in self.size]
        self.vacuum = gtk.Adjustment(10.0, 0, 100.0, 0.1)
        vacuum_box = gtk.SpinButton(self.vacuum, 0.0, 1)
        pack(vbox, [gtk.Label(_('Size: \tx: ')), buttons[0],
                    gtk.Label(_(' unit cells'))])
        pack(vbox, [gtk.Label(_('\t\ty: ')), buttons[1],
                    gtk.Label(_(' unit cells'))])
        pack(vbox, [gtk.Label(_('      \t\tz: ')), buttons[2],
                    gtk.Label(_(' layers,  ')),
                    vacuum_box, gtk.Label(_(u' Å vacuum'))])
        self.nosize = _('\t\tNo size information yet.')
        self.sizelabel = gtk.Label(self.nosize)
        pack(vbox, [self.sizelabel])
        for s in self.size:
            s.connect('value-changed', self.update)
        self.vacuum.connect('value-changed', self.update)
        pack(vbox, gtk.Label(''))

        # Buttons
        self.pybut = PyButton(_('Creating a surface slab.'))
        self.pybut.connect('clicked', self.update)
        buts = cancel_apply_ok(cancel=lambda widget: self.destroy(),
                               apply=self.apply,
                               ok=self.ok)
        pack(vbox, [self.pybut, buts], end=True, bottom=True)
        
        self.add(vbox)
        vbox.show()
        self.show()
        self.gui = gui

        # Hide the HCP stuff to begin with.
        self.vbox_hcp.hide_all()
Esempio n. 8
0
    def __init__(self, gui):
        SetupWindow.__init__(self)
        self.set_title("Surface")
        self.atoms = None

        vbox = gtk.VBox()

        # Intoductory text
        self.packtext(vbox, introtext)
             
        # Choose the element
        label = gtk.Label("Element: ")
        element = gtk.Entry(max=3)
        self.element = element
        self.elementinfo = gtk.Label("")
        pack(vbox, [label, element, self.elementinfo])
        self.element.connect('activate', self.update)
        self.legal_element = False
        
        # Choose the surface structure
        label = gtk.Label("Structure: ")
        self.structchoice = gtk.combo_box_new_text()
        self.surfinfo = {}
        for s in surfaces:
            assert len(s) == 5
            self.structchoice.append_text(s[0])
            self.surfinfo[s[0]] = s
        pack(vbox, [label, self.structchoice])
        self.structchoice.connect('changed', self.update)

        # Choose the lattice constant
        tbl = gtk.Table(2, 3)
        label = gtk.Label("Lattice constant: ")
        tbl.attach(label, 0, 1, 0, 1)
        vbox2 = gtk.VBox()          # For the non-HCP stuff
        self.vbox_hcp = gtk.VBox()  # For the HCP stuff.
        self.lattice_const = gtk.Adjustment(3.0, 0.0, 1000.0, 0.01)
        lattice_box = gtk.SpinButton(self.lattice_const, 10.0, 3)
        lattice_box.numeric = True
        pack(vbox2, [gtk.Label("a:"), lattice_box, gtk.Label("Å")])
        tbl.attach(vbox2, 1, 2, 0, 1)
        lattice_button = gtk.Button("Get from database")
        tbl.attach(lattice_button, 2, 3, 0, 1)
        # HCP stuff
        self.hcp_ideal = (8.0/3)**(1.0/3)
        self.lattice_const_c = gtk.Adjustment(self.lattice_const.value * self.hcp_ideal,
                                              0.0, 1000.0, 0.01)
        lattice_box_c = gtk.SpinButton(self.lattice_const_c, 10.0, 3)
        lattice_box_c.numeric = True
        pack(self.vbox_hcp, [gtk.Label("c:"), lattice_box_c, gtk.Label("Å")])
        self.hcp_c_over_a_format = "c/a: %.3f (%.1f %% of ideal)"
        self.hcp_c_over_a_label = gtk.Label(self.hcp_c_over_a_format % (self.hcp_ideal,
                                                                        100.0))
        pack(self.vbox_hcp, [self.hcp_c_over_a_label])
        tbl.attach(self.vbox_hcp, 1, 2, 1, 2)
        tbl.show_all()
        pack(vbox, [tbl])
        self.lattice_const.connect('value-changed', self.update)
        self.lattice_const_c.connect('value-changed', self.update)
        lattice_button.connect('clicked', self.get_lattice_const)
        pack(vbox, gtk.Label(""))

        # System size
        self.size = [gtk.Adjustment(1, 1, 100, 1) for i in range(3)]
        buttons = [gtk.SpinButton(s, 0, 0) for s in self.size]
        self.vacuum = gtk.Adjustment(10.0, 0, 100.0, 0.1)
        vacuum_box = gtk.SpinButton(self.vacuum, 0.0, 1)
        pack(vbox, [gtk.Label("Size: \tx: "), buttons[0],
                    gtk.Label(" unit cells")])
        pack(vbox, [gtk.Label("\t\ty: "), buttons[1],
                    gtk.Label(" unit cells")])
        pack(vbox, [gtk.Label("      \t\tz: "), buttons[2],
                    gtk.Label(" layers,  "),
                    vacuum_box, gtk.Label(" Å vacuum")])
        self.nosize = "\t\tNo size information yet."
        self.sizelabel = gtk.Label(self.nosize)
        pack(vbox, [self.sizelabel])
        for s in self.size:
            s.connect('value-changed', self.update)
        self.vacuum.connect('value-changed', self.update)
        pack(vbox, gtk.Label(""))

        # Buttons
        self.pybut = PyButton("Creating a surface slab.")
        self.pybut.connect('clicked', self.update)
        buts = cancel_apply_ok(cancel=lambda widget: self.destroy(),
                               apply=self.apply,
                               ok=self.ok)
        pack(vbox, [self.pybut, buts], end=True, bottom=True)
        
        self.add(vbox)
        vbox.show()
        self.show()
        self.gui = gui

        # Hide the HCP stuff to begin with.
        self.vbox_hcp.hide_all()
Esempio n. 9
0
    def __init__(self, gui):
        SetupWindow.__init__(self)
        self.set_title(_("Graphene"))
        vbox = gtk.VBox()

        # Intoductory text
        self.packtext(vbox, introtext)

        # Choose structure
        label = gtk.Label(_("Structure: "))
        self.struct = gtk.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 = gtk.Label(_("Orientation: "))
        self.orient = gtk.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, gtk.Label(""))

        # Choose the element and bond length
        label1 = gtk.Label("Element: ")
        #label.set_alignment(0.0, 0.2)
        self.element = gtk.Entry(max=3)
        self.element.set_text("C")
        self.bondlength = gtk.Adjustment(1.42, 0.0, 1000.0, 0.01)
        label2 = gtk.Label(_("  Bond length: "))
        label3 = gtk.Label(_(u"Å"))
        bond_box = gtk.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 = gtk.Label(_("Saturation: "))
        #label.set_alignment(0.0, 0.2)
        self.element2 = gtk.Entry(max=3)
        self.element2.set_text(_("H"))
        self.bondlength2 = gtk.Adjustment(1.12, 0.0, 1000.0, 0.01)
        self.sat_label2 = gtk.Label(_("  Bond length: "))
        self.sat_label3 = gtk.Label(_(u"Å"))
        self.bond_box = gtk.SpinButton(self.bondlength2, 10.0, 3)
        pack(vbox, [self.sat_label1, self.element2, self.sat_label2,
                    self.bond_box, self.sat_label3])

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

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

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

        self.status = gtk.Label("")
        pack(vbox,[self.status])
        pack(vbox,[gtk.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
Esempio n. 10
0
    def __init__(self, gui):
        SetupWindow.__init__(self)
        self.set_title(_("Create Bulk Crystal by Spacegroup"))
        self.atoms = None
        vbox = gtk.VBox()
        self.packtext(vbox, introtext)
        self.structinfo = gtk.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 = gtk.Entry(max=14)
        self.spacegroup.set_text('P 1')
        self.elementinfo = gtk.Label("")
        self.spacegroupinfo = gtk.Label(_('Number: 1'))
        pack(vbox,[gtk.Label(_("Lattice: ")),self.structinfo,gtk.Label(_("\tSpace group: ")),self.spacegroup,gtk.Label('  '),self.spacegroupinfo,gtk.Label('  '),self.elementinfo])
        pack(vbox,[gtk.Label("")])
        self.size = [gtk.Adjustment(1, 1, 100, 1) for i in range(3)]
        buttons = [gtk.SpinButton(s, 0, 0) for s in self.size]
        pack(vbox, [gtk.Label(_("Size: x: ")), buttons[0],
                    gtk.Label(_("  y: ")), buttons[1],
                    gtk.Label(_("  z: ")), buttons[2],
                    gtk.Label(_(" unit cells"))])
        pack(vbox,[gtk.Label("")])
        self.lattice_lengths = [gtk.Adjustment(3.0, 0.0, 1000.0, 0.01) for i in range(3)]
        self.lattice_angles  = [gtk.Adjustment(90.0,0.0, 180.0, 1) for i in range(3)]
        self.lattice_lbuts = [gtk.SpinButton(self.lattice_lengths[i], 0, 0) for i in range(3)]
        self.lattice_abuts = [gtk.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 = [gtk.combo_box_new_text() for i in range(3)]
        self.lattice_aequals = [gtk.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,[gtk.Label(_('Lattice parameters'))])
        pack(vbox,[gtk.Label(_('\t\ta:\t'))  , self.lattice_lbuts[0],gtk.Label('  '),self.lattice_lequals[0],
                   gtk.Label(_('\talpha:\t')), self.lattice_abuts[0],gtk.Label('  '),self.lattice_aequals[0]])
        pack(vbox,[gtk.Label(_('\t\tb:\t'))  , self.lattice_lbuts[1],gtk.Label('  '),self.lattice_lequals[1],
                   gtk.Label(_('\tbeta:\t')) , self.lattice_abuts[1],gtk.Label('  '),self.lattice_aequals[1]])
        pack(vbox,[gtk.Label(_('\t\tc:\t'))  , self.lattice_lbuts[2],gtk.Label('  '),self.lattice_lequals[2],
                   gtk.Label(_('\tgamma:\t')), self.lattice_abuts[2],gtk.Label('  '),self.lattice_aequals[2]])
        self.get_data = gtk.Button(_("Get from database"))
        self.get_data.connect("clicked", self.get_from_database)
        self.get_data.set_sensitive(False)
        pack(vbox,[gtk.Label("     "),self.get_data])
        pack(vbox,[gtk.Label("")])
        pack(vbox,[gtk.Label(_("Basis: "))])
        self.elements = [[gtk.Entry(max=3),gtk.Entry(max=8),gtk.Entry(max=8),gtk.Entry(max=8),True]]
        self.element = self.elements[0][0]
        add_atom = gtk.Button(stock = gtk.STOCK_ADD)
        add_atom.connect("clicked",self.add_basis_atom)
        add_atom.connect("activate",self.add_basis_atom)
        pack(vbox,[gtk.Label(_('  Element:\t')),self.elements[0][0],gtk.Label(_('\tx: ')),
                   self.elements[0][1],gtk.Label(_('  y: ')),self.elements[0][2],
                   gtk.Label(_('  z: ')),self.elements[0][3],gtk.Label('\t'),add_atom])
        self.vbox_basis = gtk.VBox()
        swin = gtk.ScrolledWindow()
        swin.set_border_width(0)
        swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        vbox.pack_start(swin, True, True, 0)
        swin.add_with_viewport(self.vbox_basis)
        self.vbox_basis.get_parent().set_shadow_type(gtk.SHADOW_NONE)
        self.vbox_basis.get_parent().set_size_request(-1, 100)
        swin.show()

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

        clear = gtk.Button(stock = gtk.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()
Esempio n. 11
0
    def __init__(self, gui):
        SetupWindow.__init__(self)
        self.set_title(_("Nanoparticle"))
        self.atoms = None
        self.no_update = True
        
        vbox = gtk.VBox()

        # Intoductory text
        self.packtext(vbox, introtext)
           
        # Choose the element
        label = gtk.Label(_("Element: "))
        label.set_alignment(0.0, 0.2)
        element = gtk.Entry(max=3)
        self.element = element
        lattice_button = gtk.Button(_("Get structure"))
        lattice_button.connect('clicked', self.set_structure_data)
        self.elementinfo = gtk.Label(" ")
        pack(vbox, [label, element, self.elementinfo, lattice_button], end=True)
        self.element.connect('activate', self.update)
        self.legal_element = False

        # The structure and lattice constant
        label = gtk.Label(_("Structure: "))
        self.structure = gtk.combo_box_new_text()
        self.list_of_structures = []
        self.needs_4index = {}
        self.needs_2lat = {}
        self.factory = {}
        for abbrev, name, n4, c, factory in self.structure_data:
            self.structure.append_text(name)
            self.list_of_structures.append(abbrev)
            self.needs_4index[abbrev] = n4
            self.needs_2lat[abbrev] = c
            self.factory[abbrev] = factory
        self.structure.set_active(0)
        self.fourindex = self.needs_4index[self.list_of_structures[0]]
        self.structure.connect('changed', self.update_structure)
        
        label2 = gtk.Label(_("Lattice constant:  a ="))
        self.lattice_const_a = gtk.Adjustment(3.0, 0.0, 1000.0, 0.01)
        self.lattice_const_c = gtk.Adjustment(5.0, 0.0, 1000.0, 0.01)
        self.lattice_box_a = gtk.SpinButton(self.lattice_const_a, 10.0, 3)
        self.lattice_box_c = gtk.SpinButton(self.lattice_const_c, 10.0, 3)
        self.lattice_box_a.numeric = True
        self.lattice_box_c.numeric = True
        self.lattice_label_c = gtk.Label(" c =")
        pack(vbox, [label, self.structure])
        pack(vbox, [label2, self.lattice_box_a,
                    self.lattice_label_c, self.lattice_box_c])
        self.lattice_label_c.hide()
        self.lattice_box_c.hide()
        self.lattice_const_a.connect('value-changed', self.update)
        self.lattice_const_c.connect('value-changed', self.update)

        # Choose specification method
        label = gtk.Label(_("Method: "))
        self.method = gtk.combo_box_new_text()
        for meth in (_("Layer specification"), _("Wulff construction")):
            self.method.append_text(meth)
        self.method.set_active(0)
        self.method.connect('changed', self.update_gui_method)
        pack(vbox, [label, self.method])
        pack(vbox, gtk.Label(""))
        self.old_structure = None

        frame = gtk.Frame()
        pack(vbox, frame)
        framebox = gtk.VBox()
        frame.add(framebox)
        framebox.show()
        self.layerlabel = gtk.Label("Missing text")  # Filled in later
        pack(framebox, [self.layerlabel])
        # This box will contain a single table that is replaced when
        # the list of directions is changed.
        self.direction_table_box = gtk.VBox()
        pack(framebox, self.direction_table_box)
        pack(self.direction_table_box, 
             gtk.Label(_("Dummy placeholder object")))
        pack(framebox, gtk.Label(""))
        pack(framebox, [gtk.Label(_("Add new direction:"))])
        self.newdir_label = []
        self.newdir_box = []
        self.newdir_index = []
        packlist = []
        for txt in ('(', ', ', ', ', ', '):
            self.newdir_label.append(gtk.Label(txt))
            adj = gtk.Adjustment(0, -100, 100, 1)
            self.newdir_box.append(gtk.SpinButton(adj, 1, 0))
            self.newdir_index.append(adj)
            packlist.append(self.newdir_label[-1])
            packlist.append(self.newdir_box[-1])
        self.newdir_layers = gtk.Adjustment(5, 0, 100, 1)
        self.newdir_layers_box = gtk.SpinButton(self.newdir_layers, 1, 0)
        self.newdir_esurf = gtk.Adjustment(1.0, 0, 1000.0, 0.1)
        self.newdir_esurf_box = gtk.SpinButton(self.newdir_esurf, 10, 3)
        addbutton = gtk.Button(_("Add"))
        addbutton.connect('clicked', self.row_add)
        packlist.extend([gtk.Label("): "),
                         self.newdir_layers_box,
                         self.newdir_esurf_box,
                         gtk.Label("  "),
                         addbutton])
        pack(framebox, packlist)
        self.defaultbutton = gtk.Button(_("Set all directions to default "
                                          "values"))
        self.defaultbutton.connect('clicked', self.default_direction_table)
        self.default_direction_table()

        # Extra widgets for the Wulff construction
        self.wulffbox = gtk.VBox()
        pack(vbox, self.wulffbox)
        label = gtk.Label(_("Particle size: "))
        self.size_n_radio = gtk.RadioButton(None, _("Number of atoms: "))
        self.size_n_radio.set_active(True)
        self.size_n_adj = gtk.Adjustment(100, 1, 100000, 1)
        self.size_n_spin = gtk.SpinButton(self.size_n_adj, 0, 0)
        self.size_dia_radio = gtk.RadioButton(self.size_n_radio,
                                              _("Volume: "))
        self.size_dia_adj = gtk.Adjustment(1.0, 0, 100.0, 0.1)
        self.size_dia_spin = gtk.SpinButton(self.size_dia_adj, 10.0, 2)
        pack(self.wulffbox, [label, self.size_n_radio, self.size_n_spin,
                    gtk.Label("   "), self.size_dia_radio, self.size_dia_spin,
                    gtk.Label(_(u"ų"))])
        self.size_n_radio.connect("toggled", self.update_gui_size)
        self.size_dia_radio.connect("toggled", self.update_gui_size)
        self.size_n_adj.connect("value-changed", self.update_size_n)
        self.size_dia_adj.connect("value-changed", self.update_size_dia)
        label = gtk.Label(_("Rounding: If exact size is not possible, "
                            "choose the size"))
        pack(self.wulffbox, [label])
        self.round_above = gtk.RadioButton(None, _("above  "))
        self.round_below = gtk.RadioButton(self.round_above, _("below  "))
        self.round_closest = gtk.RadioButton(self.round_above, _("closest  "))
        self.round_closest.set_active(True)
        butbox = gtk.HButtonBox()
        self.smaller_button = gtk.Button(_("Smaller"))
        self.larger_button = gtk.Button(_("Larger"))
        self.smaller_button.connect('clicked', self.wulff_smaller)
        self.larger_button.connect('clicked', self.wulff_larger)
        pack(butbox, [self.smaller_button, self.larger_button])
        buts = [self.round_above, self.round_below, self.round_closest]
        for b in buts:
            b.connect("toggled", self.update)
        buts.append(butbox)
        pack(self.wulffbox, buts, end=True)

        # Information
        pack(vbox, gtk.Label(""))
        infobox = gtk.VBox()
        label1 = gtk.Label(_("Number of atoms: "))
        self.natoms_label = gtk.Label("-")
        label2 = gtk.Label(_("   Approx. diameter: "))
        self.dia1_label = gtk.Label("-")
        pack(infobox, [label1, self.natoms_label, label2, self.dia1_label])
        pack(infobox, gtk.Label(""))
        infoframe = gtk.Frame(_("Information about the created cluster:"))
        infoframe.add(infobox)
        infobox.show()
        pack(vbox, infoframe)
        
        # Buttons
        self.pybut = PyButton(_("Creating a nanoparticle."))
        self.pybut.connect('clicked', self.makeatoms)
        helpbut = help(helptext)
        buts = cancel_apply_ok(cancel=lambda widget: self.destroy(),
                               apply=self.apply,
                               ok=self.ok)
        pack(vbox, [self.pybut, helpbut, buts], end=True, bottom=True)
        self.auto = gtk.CheckButton(_("Automatic Apply"))
        fr = gtk.Frame()
        fr.add(self.auto)
        fr.show_all()
        pack(vbox, [fr], end=True, bottom=True)
        
        # Finalize setup
        self.update_structure()
        self.update_gui_method()
        self.add(vbox)
        vbox.show()
        self.show()
        self.gui = gui
        self.no_update = False