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: values.append(key) labels.append('By user-defined "{}"'.format(key)) self.radio = ui.RadioButtons(labels, values, self.toggle, vertical=True) self.radio.value = gui.colormode self.win.add(self.radio) self.activate() self.label = ui.Label() self.win.add(self.label) if hasattr(self, 'mnmx'): self.win.add(self.cmaps) self.win.add(self.mnmx)
def window(): def hello(event=None): print('hello', event) menu = [('Hi', [ui.MenuItem('_Hello', hello, 'Ctrl+H')]), ('Hell_o', [ui.MenuItem('ABC', hello, choices='ABC')])] win = ui.MainWindow('Test', menu=menu) win.add(ui.Label('Hello')) win.add(ui.Button('Hello', hello)) r = ui.Rows([ui.Label(x * 7) for x in 'abcd']) win.add(r) r.add('11111\n2222\n333\n44\n5') def abc(x): print(x, r.rows) cb = ui.ComboBox(['Aa', 'Bb', 'Cc'], callback=abc) win.add(cb) rb = ui.RadioButtons(['A', 'B', 'C'], 'ABC', abc) win.add(rb) b = ui.CheckButton('Hello') def hi(): print(b.value, rb.value, cb.value) del r[2] r.add('-------------') win.add([b, ui.Button('Hi', hi)]) return win
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()
def __init__(self, gui): 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' ] labels = [ _('By atomic number, default "jmol" colors'), _('By tag'), _('By force'), _('By velocity'), _('By initial charge'), _('By magnetic moment') ] self.radio = ui.RadioButtons(labels, values, self.toggle, vertical=True) self.radio.value = gui.colormode self.win.add(self.radio) self.activate() self.label = ui.Label() self.win.add(self.label)
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()
def __init__(self): ui.Window.__init__(self) self.set_title(_("Progress")) self.globalbox = ui.VBox() self.nextupdate = 0 self.fmax_max = 1.0 # Scaling deformation progress frame self.scalebox = ui.VBox() self.scaleframe = ui.Frame(_("Scaling deformation:")) vbox = ui.VBox() self.scaleframe.add(vbox) pack(self.scalebox, [self.scaleframe]) pack(self.scalebox, ui.Label("")) self.label_scale_stepno_format = _("Step number %s of %s.") self.label_scale_stepno = ui.Label(self.label_scale_stepno_format % ("-", "-")) pack(vbox, [self.label_scale_stepno]) self.scale_progress = ui.ProgressBar() self.scale_progress.modify_bg(ui.STATE_PRELIGHT, '#00AA00') pack(vbox, [self.scale_progress]) vbox.show() self.scaleframe.show() self.globalbox.pack_start(self.scalebox) # Minimization progress frame self.minbox = ui.VBox() # Box containing frame and spacing self.minframe = ui.Frame(_("Energy minimization:")) vbox = ui.VBox() # Box containing the frames content. self.minframe.add(vbox) pack(self.minbox, [self.minframe]) pack(self.minbox, ui.Label("")) self.label_min_stepno = ui.Label("-") pack(vbox, [ui.Label(_("Step number: ")), self.label_min_stepno]) lbl = ui.Label() lbl.set_markup(_("F<sub>max</sub>: ")) self.minimize_progress = ui.ProgressBar() pack(vbox, [lbl, self.minimize_progress]) self.label_min_fmax = ui.Label("-") lbl = ui.Label() lbl.set_markup(_("Convergence criterion: F<sub>max</sub> = ")) pack(vbox, [lbl, self.label_min_fmax]) self.label_min_maxsteps = ui.Label("-") pack(vbox, [ui.Label(_("Max. number of steps: ")), self.label_min_maxsteps]) vbox.show() self.minframe.show() self.globalbox.pack_start(self.minbox) self.globalbox.show() self.add(self.globalbox) # Make the cancel button self.cancelbut = ui.Button('Cancel') self.cancelbut.connect('clicked', self.cancel) pack(self.globalbox, [self.cancelbut], end=True, bottom=True)
def packtext(self, vbox, text, label=None): "Pack an text frame into the window." pack(vbox, ui.Label("")) txtframe = ui.Frame(label) txtlbl = ui.Label(text) txtframe.add(txtlbl) txtlbl.show() pack(vbox, txtframe) pack(vbox, ui.Label(""))
def __init__(self, gui): ui.Window.__init__(self) self.gui = gui self.set_title(_('Expert user mode')) vbox = ui.VBox() vbox.set_border_width(5) self.sw = ui.ScrolledWindow() self.sw.set_policy(ui.POLICY_AUTOMATIC, ui.POLICY_AUTOMATIC) self.textview = ui.TextView() self.textbuffer = self.textview.get_buffer() self.textview.set_editable(False) self.textview.set_cursor_visible(False) self.sw.add(self.textview) pack(vbox, self.sw, expand=True, padding=5) self.sw.set_size_request(540, 150) self.textview.show() self.add_text(_('Welcome to the ASE Expert user mode')) self.cmd = ui.Entry(60) self.cmd.connect('activate', self.execute) self.cmd.connect('key-press-event', self.update_command_buffer) pack(vbox, [ui.Label('>>>'), self.cmd]) self.cmd_buffer = getattr(gui, 'expert_mode_buffer', ['']) self.cmd_position = len(self.cmd_buffer) - 1 self.selected = ui.CheckButton(_('Only selected atoms (sa) ')) self.selected.connect('toggled', self.selected_changed) self.images_only = ui.CheckButton(_('Only current frame (cf) ')) self.images_only.connect('toggled', self.images_changed) pack(vbox, [self.selected, self.images_only]) save_button = ui.Button(_('Save')) save_button.connect('clicked', self.save_output) help_button = ui.Button(_('Help')) help_button.connect('clicked', self.terminal_help, "") stop_button = ui.Button(_('Stop')) stop_button.connect('clicked', self.stop_execution) self.stop = False pack(vbox, [ ui.Label( _('Global: Use A, D, E, M, N, R, S, n, frame;' ' Atoms: Use a, f, m, s, x, y, z, Z ')), stop_button, help_button, save_button ], end=True) self.add(vbox) vbox.show() self.show() # set color mode to manual when opening this window for rgb # manipulation self.colors = self.gui.get_colors() rgb_data = self.gui.get_colors(rgb=True) self.rgb_data = [] # ensure proper format of rgb_data for i, rgb in enumerate(rgb_data): self.rgb_data += [[i, rgb]] self.gui.colordata = self.rgb_data self.gui.colors = list(self.colors) self.gui.colormode = 'manual' self.cmd.grab_focus()
def open(self, button=None, filename=None): from ase.io.formats import all_formats, get_ioformat labels = [_('Automatic')] values = [''] def key(item): return item[1][0] for format, (description, code) in sorted(list(all_formats.items()), key=key): io = get_ioformat(format) if io.read and description != '?': labels.append(_(description)) values.append(format) format = [None] def callback(value): format[0] = value chooser = ui.LoadFileDialog(self.window.win, _('Open ...')) ui.Label(_('Choose parser:')).pack(chooser.top) formats = ui.ComboBox(labels, values, callback) formats.pack(chooser.top) filename = filename or chooser.go() if filename: self.images.read([filename], slice(None), format[0]) self.set_colors() self.set_coordinates(self.images.nimages - 1, focus=True)
def add_basis_atom(self, *args): """ add an atom to the customizable basis """ n = len(self.elements) self.elements += [[ ui.Entry(max=3), ui.Entry(max=8), ui.Entry(max=8), ui.Entry(max=8), ui.Label('\t\t\t'), ui.Label('\tx: '), ui.Label(' y: '), ui.Label(' z: '), ui.Label(' '), ui.Button('Delete'), True ]] self.elements[n][-2].connect("clicked", self.delete_basis_atom, {'n': n}) pack(self.vbox_basis, [ self.elements[n][4], self.elements[n][0], self.elements[n][5], self.elements[n][1], self.elements[n][6], self.elements[n][2], self.elements[n][7], self.elements[n][3], self.elements[n][8], self.elements[n][9] ]) self.update()
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]) win.add([_('Lattice constant:')]) win.add([_('\ta'), self.lattice_a, (u'Å'), self.retrieve]) win.add([_('\tc'), self.lattice_c, (u'Å')]) win.add([_('Size:')]) win.add([_('\tx: '), self.x, _(' unit cells'), self.x_warn]) win.add([_('\ty: '), self.y, _(' unit cells'), self.y_warn]) win.add([_('\tz: '), self.z, _(' unit cells')]) win.add([_('Vacuum: '), self.vacuum_check, self.vacuum, (u'Å')]) win.add(self.description) # TRANSLATORS: This is a title of a window. win.add([ pybutton(_('Creating a surface.'), self.make), ui.Button(_('Apply'), self.apply), ui.Button(_('OK'), self.ok) ]) self.element.grab_focus() self.gui = gui self.atoms = None self.lattice_c.active = False self.vacuum.active = False self.structure_changed()
def __init__(self, symbol='', callback=None): list.__init__(self, [ _('Element:'), ui.Entry(symbol, 3, self.enter), ui.Button(_('Help'), self.show_help), ui.Label('', 'red') ]) self.callback = callback
def __init__(self, symbol='', callback=None): list.__init__(self, [ _('Element:'), ui.Entry(symbol, 3, self.enter), ui.Label('', 'red') ]) self.callback = callback self._symbol = None self._Z = None
def __init__(self, symbol='', callback=None, allow_molecule=False): list.__init__(self, [ _('Element:'), ui.Entry(symbol, 10 if allow_molecule else 3, self.enter), ui.Button(_('Help'), self.show_help), ui.Label('', 'red') ]) self.callback = callback self.allow_molecule = allow_molecule
def __init__(self, gui): Simulation.__init__(self, gui) self.set_title(_("Energy minimization")) vbox = ui.VBox() self.packtext(vbox, _("Minimize the energy with respect to the positions.")) self.packimageselection(vbox) pack(vbox, ui.Label("")) self.make_minimize_gui(vbox) pack(vbox, ui.Label("")) self.status_label = ui.Label("") pack(vbox, [self.status_label]) self.makebutbox(vbox) vbox.show() self.add(vbox) self.show() self.gui.register_vulnerable(self)
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) self.show() self.gui.register_vulnerable(self)
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!'))
def makeoutputfield(self, box, label=_("Output:"), heading=None): frame = ui.Frame(label) if box is not None: box.pack_start(frame, True, True, 0) box2 = ui.VBox() frame.add(box2) if heading is not None: pack(box2, [ui.Label(heading)]) scrwin = ui.ScrolledWindow() scrwin.set_policy(ui.POLICY_AUTOMATIC, ui.POLICY_AUTOMATIC) self.output = ui.TextBuffer() txtview = ui.TextView(self.output) txtview.set_editable(False) scrwin.add(txtview) scrwin.show_all() box2.pack_start(scrwin, True, True, 0) self.savebutton = ui.Button('Save') self.savebutton.connect('clicked', self.saveoutput) self.savebutton.set_sensitive(False) pack(box2, [self.savebutton]) box2.show() frame.show() return frame
def __init__(self, gui): self.element = Element('C', self.make) self.bondlength = ui.SpinBox(1.42, 0.0, 10.0, 0.01, self.make) self.n = ui.SpinBox(5, 1, 100, 1, self.make) self.m = ui.SpinBox(5, 0, 100, 1, self.make) self.length = ui.SpinBox(1, 1, 100, 1, self.make) self.description = ui.Label('') win = self.win = ui.Window(_('Nanotube')) win.add(ui.Text(introtext)) win.add(self.element) win.add([_('Bond length: '), self.bondlength, _(u'Å')]) win.add(_('Select roll-up vector (n,m) and tube length:')) win.add(['n:', self.n, 'm:', self.m, _('Length:'), self.length]) win.add(self.description) win.add([ pybutton(_('Creating a nanoparticle.'), self.make), ui.Button(_('Apply'), self.apply), ui.Button(_('OK'), self.ok) ]) self.gui = gui self.atoms = None
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()
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:')), self.texture_widget]) # complicated texture stuff self.camera_widget = ui.ComboBox(labels=self.cameras, values=self.cameras) self.camera_distance_widget = ui.SpinBox(50.0, -99.0, 99.0, 1.0) win.add([ui.Label(_('Camera type: ')), self.camera_widget]) win.add([ui.Label(_('Camera distance')), self.camera_distance_widget]) # render current frame/all frames self.frames_widget = ui.RadioButtons( [_('Render current frame'), _('Render all frames')]) win.add(self.frames_widget) if len(gui.images) == 1: self.frames_widget.buttons[1].widget.configure(state='disabled') self.run_povray_widget = ui.CheckButton(_('Run povray'), True) self.keep_files_widget = ui.CheckButton(_('Keep povray files'), False) self.show_output_widget = ui.CheckButton(_('Show output window'), True) self.transparent = ui.CheckButton(_("Transparent background"), True) win.add(self.transparent) win.add([ self.run_povray_widget, self.keep_files_widget, self.show_output_widget ]) win.add(ui.Button(_('Render'), self.ok))
def __init__(self): DefaultProgressIndicator.__init__(self) # GPAW progress frame self.gpawframe = ui.Frame("GPAW progress:") vbox = self.gpawvbox = ui.VBox() self.gpawframe.add(vbox) self.table = ui.Table(1, 2) self.tablerows = 0 pack(vbox, self.table) self.status = ui.Label("-") self.tablepack([ui.Label(_("Status: ")), self.status]) self.iteration = ui.Label("-") self.tablepack([ui.Label(_("Iteration: ")), self.iteration]) self.tablepack([ui.Label("")]) lbl = ui.Label() lbl.set_markup(_("log<sub>10</sub>(change):")) self.tablepack([ui.Label(""), lbl]) self.wfs_progress = ui.ProgressBar() self.tablepack([ui.Label(_("Wave functions: ")), self.wfs_progress]) self.dens_progress = ui.ProgressBar() self.tablepack([ui.Label(_("Density: ")), self.dens_progress]) self.energy_progress = ui.ProgressBar() self.tablepack([ui.Label(_("Energy: ")), self.energy_progress]) self.tablepack([ui.Label("")]) self.versionlabel = ui.Label("") self.tablepack([ui.Label(_("GPAW version: ")), self.versionlabel]) self.natomslabel = ui.Label("") self.tablepack([ui.Label(_("Number of atoms: ")), self.natomslabel]) self.memorylabel = ui.Label(_("N/A")) self.tablepack([ui.Label(_("Memory estimate: ")), self.memorylabel]) self.globalbox.pack_start(self.gpawframe) self.gpawframe.show() vbox.show() self.active = False
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()
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
def __init__(self, gui): self.atoms = None self.no_update = True self.old_structure = 'undefined' win = self.win = ui.Window(_('Nanoparticle')) win.add(ui.Text(introtext)) self.element = Element('', self.apply) lattice_button = ui.Button(_('Get structure'), self.set_structure_data) self.elementinfo = ui.Label(' ') win.add(self.element) win.add(self.elementinfo) win.add(lattice_button) # The structure and lattice constant labels = [] values = [] self.needs_4index = {} self.needs_2lat = {} self.factory = {} for abbrev, name, n4, c, factory in self.structure_data: labels.append(name) values.append(abbrev) self.needs_4index[abbrev] = n4 self.needs_2lat[abbrev] = c self.factory[abbrev] = factory self.structure = ui.ComboBox(labels, values, self.update_structure) win.add([_('Structure:'), self.structure]) self.fourindex = self.needs_4index[values[0]] self.a = ui.SpinBox(3.0, 0.0, 1000.0, 0.01, self.update) self.c = ui.SpinBox(3.0, 0.0, 1000.0, 0.01, self.update) win.add([_('Lattice constant: a ='), self.a, ' c =', self.c]) # Choose specification method self.method = ui.ComboBox( [_('Layer specification'), _('Wulff construction')], ['layers', 'wulff'], self.update_gui_method) win.add([_('Method: '), self.method]) self.layerlabel = ui.Label('Missing text') # Filled in later win.add(self.layerlabel) self.direction_table_rows = ui.Rows() win.add(self.direction_table_rows) self.default_direction_table() win.add(_('Add new direction:')) self.new_direction_and_size_rows = ui.Rows() win.add(self.new_direction_and_size_rows) self.update_new_direction_and_size_stuff() # Information win.add(_('Information about the created cluster:')) self.info = [ _('Number of atoms: '), ui.Label('-'), _(' Approx. diameter: '), ui.Label('-') ] win.add(self.info) # Finalize setup self.update_structure('fcc') self.update_gui_method() self.no_update = False self.auto = ui.CheckButton(_('Automatic Apply')) win.add(self.auto) win.add([ pybutton(_('Creating a nanoparticle.'), self.makeatoms), ui.helpbutton(helptext), ui.Button(_('Apply'), self.apply), ui.Button(_('OK'), self.ok) ]) self.gui = gui self.smaller_button = None self.largeer_button = None self.element.grab_focus()