def __init__(self, gui): gtk.Window.__init__(self) #self.window.set_position(gtk.WIN_POS_CENTER) #self.window.connect("destroy", lambda w: gtk.main_quit()) #self.window.connect('delete_event', self.exit) self.set_title('Graphs') vbox = gtk.VBox() self.expr = pack(vbox, [gtk.Entry(64), help(graph_help_text)])[0] self.expr.connect('activate', self.plot) completion = gtk.EntryCompletion() self.liststore = gtk.ListStore(str) for s in ['fmax', 's, e-E[0]', 'i, d(0,1)']: self.liststore.append([s]) completion.set_model(self.liststore) self.expr.set_completion(completion) completion.set_text_column(0) button = pack(vbox, [gtk.Button(_('Plot')), gtk.Label(' x, y1, y2, ...')])[0] button.connect('clicked', self.plot, 'xy') button = pack(vbox, [gtk.Button(_('Plot')), gtk.Label(' y1, y2, ...')])[0] button.connect('clicked', self.plot, 'y') save_button = gtk.Button(stock=gtk.STOCK_SAVE) save_button.connect('clicked', self.save) clear_button = gtk.Button(_('clear')) clear_button.connect('clicked', self.clear) pack(vbox, [save_button, clear_button]) self.add(vbox) vbox.show() self.show() self.gui = gui
def __init__(self, gui): gtk.Window.__init__(self) #self.window.set_position(gtk.WIN_POS_CENTER) #self.window.connect("destroy", lambda w: gtk.main_quit()) #self.window.connect('delete_event', self.exit) self.set_title('Graphs') vbox = gtk.VBox() self.expr = pack(vbox, [gtk.Entry(40), help('Help for plot ...')])[0] self.expr.connect('activate', self.plot) completion = gtk.EntryCompletion() self.liststore = gtk.ListStore(str) for s in ['fmax', 's, e-E[0]', 'i, d(0,1)']: self.liststore.append([s]) completion.set_model(self.liststore) self.expr.set_completion(completion) completion.set_text_column(0) button = pack(vbox, [gtk.Button('Plot'), gtk.Label(' x, y1, y2, ...')])[0] button.connect('clicked', self.plot, 'xy') button = pack(vbox, [gtk.Button('Plot'), gtk.Label(' y1, y2, ...')])[0] button.connect('clicked', self.plot, 'y') button = pack(vbox, gtk.Button(_('clear'))) button.connect('clicked', self.clear) self.add(vbox) vbox.show() self.show() self.gui = gui
def add_basis_atom(self, *args): """ add an atom to the customizable basis """ n = len(self.elements) self.elements += [ [ gtk.Entry(max=3), gtk.Entry(max=8), gtk.Entry(max=8), gtk.Entry(max=8), gtk.Label("\t\t\t"), gtk.Label("\tx: "), gtk.Label(" y: "), gtk.Label(" z: "), gtk.Label(" "), gtk.Button(stock=gtk.STOCK_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, vbox): self.eventbox = gtk.EventBox() self.label = gtk.Label() self.eventbox.add(self.label) self.label.show() self.set_tip(self.eventbox, _('Tip for status box ...')) pack(vbox, self.eventbox)
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.images.Z[n]] name = formula(Z) if (box_selection == selection).all(): name += ': ' + self.texture_selection.get_text() texture_button = gtk.combo_box_new_text() for t in self.finish_list: texture_button.append_text(t) texture_button.set_active(1) transparency = gtk.Adjustment(0,0.0,1.0,0.01) transparency_spin = gtk.SpinButton(transparency, 0, 0) transparency_spin.set_digits(2) delete_button = gtk.Button(stock=gtk.STOCK_DELETE) alignment = delete_button.get_children()[0] index = len(self.materials) delete_button.connect("clicked",self.delete_material,{"n":index}) self.materials += [[True,selection,texture_button, gtk.Label(_(" transparency: ")),transparency_spin, gtk.Label(" "),delete_button,gtk.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: oops(_("Can not create new texture! Must have some atoms selected to create a new material!"))
def __init__(self, gui): gtk.Window.__init__(self) self.set_title('Graphs') vbox = gtk.VBox() self.expr = pack(vbox, [gtk.Entry(64), help(graph_help_text)])[0] self.expr.connect('activate', self.plot) completion = gtk.EntryCompletion() self.liststore = gtk.ListStore(str) for s in ['fmax', 's, e-E[0]', 'i, d(0,1)']: self.liststore.append([s]) completion.set_model(self.liststore) self.expr.set_completion(completion) completion.set_text_column(0) button = pack(vbox, [gtk.Button(_('Plot')), gtk.Label(' x, y1, y2, ...')])[0] button.connect('clicked', self.plot, 'xy') button = pack(vbox, [gtk.Button(_('Plot')), gtk.Label(' y1, y2, ...')])[0] button.connect('clicked', self.plot, 'y') save_button = gtk.Button(stock=gtk.STOCK_SAVE) save_button.connect('clicked', self.save) clear_button = gtk.Button(_('clear')) clear_button.connect('clicked', self.clear) pack(vbox, [save_button, clear_button]) self.add(vbox) vbox.show() self.show() self.gui = gui
def __init__(self, gui): gtk.Window.__init__(self) self.set_title(_('Constraints')) vbox = gtk.VBox() b = pack(vbox, [gtk.Button(_('Constrain')), gtk.Label(_(' selected atoms'))])[0] b.connect('clicked', self.selected) b = pack( vbox, [gtk.Button(_('Constrain')), gtk.Label(_(' immobile atoms:'))])[0] b.connect('clicked', self.immobile) b = pack( vbox, [gtk.Button(_('Unconstrain')), gtk.Label(_(' selected atoms:'))])[0] b.connect('clicked', self.unconstrain) b = pack(vbox, gtk.Button(_('Clear constraints'))) b.connect('clicked', self.clear) close = pack(vbox, gtk.Button(_('Close'))) close.connect('clicked', lambda widget: self.destroy()) self.add(vbox) vbox.show() self.show() self.gui = gui
def open(self, button=None, filenames=None): if filenames == None: chooser = gtk.FileChooserDialog( _('Open ...'), None, gtk.FILE_CHOOSER_ACTION_OPEN, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK)) chooser.set_filename(_("<<filename>>")) # Add a file type filter name_to_suffix = {} types = gtk.combo_box_new_text() for name, suffix in [(_('Automatic'), None), (_('Dacapo netCDF output file'),'dacapo'), (_('Virtual Nano Lab file'),'vnl'), (_('ASE pickle trajectory'),'traj'), (_('ASE bundle trajectory'),'bundle'), (_('GPAW text output'),'gpaw-text'), (_('CUBE file'),'cube'), (_('XCrySDen Structure File'),'xsf'), (_('Dacapo text output'),'dacapo-text'), (_('XYZ-file'),'xyz'), (_('VASP POSCAR/CONTCAR file'),'vasp'), (_('VASP OUTCAR file'),'vasp_out'), (_('Protein Data Bank'),'pdb'), (_('CIF-file'),'cif'), (_('FHI-aims geometry file'),'aims'), (_('FHI-aims output file'),'aims_out'), (_('TURBOMOLE coord file'),'tmol'), (_('exciting input'),'exi'), (_('WIEN2k structure file'),'struct'), (_('DftbPlus input file'),'dftb'), (_('ETSF format'),'etsf.nc'), (_('CASTEP geom file'),'cell'), (_('CASTEP output file'),'castep'), (_('CASTEP trajectory file'),'geom'), (_('DFTBPlus GEN format'),'gen') ]: types.append_text(name) name_to_suffix[name] = suffix types.set_active(0) img_vbox = gtk.VBox() pack(img_vbox, [gtk.Label(_('File type:')), types]) img_vbox.show() chooser.set_extra_widget(img_vbox) ok = chooser.run() == gtk.RESPONSE_OK if ok: filenames = [chooser.get_filename()] filetype = types.get_active_text() chooser.destroy() if not ok: return n_current = self.images.nimages self.reset_tools_modes() self.images.read(filenames, slice(None), name_to_suffix[filetype]) self.set_colors() self.set_coordinates(self.images.nimages - 1, focus=True)
def __init__(self, gui): gtk.Window.__init__(self) self.set_position(gtk.WIN_POS_NONE) self.connect('destroy', self.close) #self.connect('delete_event', self.exit2) self.set_title('Movie') vbox = gtk.VBox() pack(vbox, gtk.Label(_('Image number:'))) self.frame_number = gtk.Adjustment(gui.frame, 0, gui.images.nimages - 1, 1.0, 5.0) self.frame_number.connect('value-changed', self.new_frame) hscale = pack(vbox, gtk.HScale(self.frame_number)) hscale.set_update_policy(gtk.UPDATE_CONTINUOUS) hscale.set_digits(0) buttons = [gtk.Button(stock=gtk.STOCK_GOTO_FIRST), gtk.Button(stock=gtk.STOCK_GO_BACK), gtk.Button(stock=gtk.STOCK_GO_FORWARD), gtk.Button(stock=gtk.STOCK_GOTO_LAST)] buttons[0].connect('clicked', self.click, -1, True) buttons[1].connect('clicked', self.click, -1) buttons[2].connect('clicked', self.click, 1) buttons[3].connect('clicked', self.click, 1, True) pack(vbox, buttons) play = gtk.Button(_('Play')) play.connect('clicked', self.play) stop = gtk.Button('Stop') stop.connect('clicked', self.stop) self.rock = gtk.CheckButton('Rock') pack(vbox, [play, stop, gtk.Label(' '), self.rock]) if gui.images.nimages > 150: skipdefault = gui.images.nimages/150 tdefault = min(max(gui.images.nimages/(skipdefault*5.0), 1.0), 30) else: skipdefault = 0 tdefault = min(max(gui.images.nimages/5.0, 1.0), 30) self.time = gtk.Adjustment(tdefault, 1.0, 99, 0.1) self.time_spin = gtk.SpinButton(self.time, 0, 0) self.time_spin.set_digits(1) self.time.connect("value-changed",self.frame_rate_changed) self.skip = gtk.Adjustment(skipdefault, 0, 99, 1) self.skip_spin = gtk.SpinButton(self.skip, 0, 0) pack(vbox, [gtk.Label(' Frame rate: '), self.time_spin, gtk.Label(' Skip frames: '), self.skip_spin, gtk.Label(' ')]) self.add(vbox) vbox.show() self.show() self.gui = gui #gui.m=self self.direction = 1 self.id = None gui.register_vulnerable(self)
def __init__(self, vbox): self.eventbox = gtk.EventBox() self.label = gtk.Label() self.eventbox.add(self.label) self.label.show() if gtk.pygtk_version < (2, 12): self.set_tip(self.eventbox, _('Tip for status box ...')) else: self.eventbox.set_tooltip_text(_('Tip for status box ...')) pack(vbox, self.eventbox) self.ordered_indices = []
def __init__(self, vbox): self.eventbox = gtk.EventBox() self.label = gtk.Label() self.eventbox.add(self.label) self.label.show() if gtk.pygtk_version < (2, 12): self.set_tip(self.eventbox, _("Tip for status box ...")) else: self.eventbox.set_tooltip_text(_("Tip for status box ...")) pack(vbox, self.eventbox) self.ordered_indices = []
def make_minimize_gui(self, box): self.algo = gtk.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, [gtk.Label(_("Algorithm: ")), self.algo]) self.fmax = gtk.Adjustment(0.05, 0.00, 10.0, 0.01) self.fmax_spin = gtk.SpinButton(self.fmax, 0, 3) lbl = gtk.Label() lbl.set_markup(_("Convergence criterion: F<sub>max</sub> = ")) pack(box, [lbl, self.fmax_spin]) self.steps = gtk.Adjustment(100, 1, 1000000, 1) self.steps_spin = gtk.SpinButton(self.steps, 0, 0) pack(box, [gtk.Label(_("Max. number of steps: ")), self.steps_spin]) # Special stuff for MDMin lbl = gtk.Label(_("Pseudo time step: ")) self.mdmin_dt = gtk.Adjustment(0.05, 0.0, 10.0, 0.01) spin = gtk.SpinButton(self.mdmin_dt, 0, 3) self.mdmin_widgets = [lbl, spin] pack(box, self.mdmin_widgets) self.min_algo_specific()
def makebutbox(self, vbox, helptext=None): self.buttons = gtk.HButtonBox() runbut = gtk.Button(_("Run")) runbut.connect('clicked', self.run) closebut = gtk.Button(stock=gtk.STOCK_CLOSE) closebut.connect('clicked', lambda x: self.destroy()) for w in (runbut, closebut): self.buttons.pack_start(w, 0, 0) w.show() if helptext: helpbut = [help(helptext)] else: helpbut = [] pack(vbox, helpbut + [self.buttons], end=True, bottom=True)
def __init__(self, gui): gtk.Window.__init__(self) self.set_title('Repeat') vbox = gtk.VBox() pack(vbox, gtk.Label(_('Repeat atoms:'))) self.repeat = [gtk.Adjustment(r, 1, 9, 1) for r in gui.images.repeat] pack(vbox, [gtk.SpinButton(r, 0, 0) for r in self.repeat]) for r in self.repeat: r.connect('value-changed', self.change) button = pack(vbox, gtk.Button('Set unit cell')) button.connect('clicked', self.set_unit_cell) self.add(vbox) vbox.show() self.show() self.gui = gui
def __init__(self, gui): gtk.Window.__init__(self) self.set_title(_('Repeat')) vbox = gtk.VBox() pack(vbox, gtk.Label(_('Repeat atoms:'))) self.repeat = [gtk.Adjustment(r, 1, 9, 1) for r in gui.images.repeat] pack(vbox, [gtk.SpinButton(r, 0, 0) for r in self.repeat]) for r in self.repeat: r.connect('value-changed', self.change) button = pack(vbox, gtk.Button(_('Set unit cell'))) button.connect('clicked', self.set_unit_cell) self.add(vbox) vbox.show() self.show() self.gui = gui
def __init__(self, gui): gtk.Window.__init__(self) self.gui = gui self.set_title(_("Expert user mode")) vbox = gtk.VBox() vbox.set_border_width(5) self.sw = gtk.ScrolledWindow() self.sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.textview = gtk.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 = gtk.Entry(60) self.cmd.connect("activate", self.execute) self.cmd.connect("key-press-event", self.update_command_buffer) pack(vbox, [gtk.Label(">>>"), self.cmd]) self.cmd_buffer = getattr(gui, "expert_mode_buffer", [""]) self.cmd_position = len(self.cmd_buffer) - 1 self.selected = gtk.CheckButton(_("Only selected atoms (sa) ")) self.selected.connect("toggled", self.selected_changed) self.images_only = gtk.CheckButton(_("Only current frame (cf) ")) self.images_only.connect("toggled", self.images_changed) pack(vbox, [self.selected, self.images_only]) save_button = gtk.Button(stock=gtk.STOCK_SAVE) save_button.connect("clicked", self.save_output) help_button = gtk.Button(stock=gtk.STOCK_HELP) help_button.connect("clicked", self.terminal_help, "") stop_button = gtk.Button(stock=gtk.STOCK_STOP) stop_button.connect("clicked", self.stop_execution) self.stop = False pack( vbox, [ gtk.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 __init__(self, gui): gtk.Window.__init__(self) #self.window.set_position(gtk.WIN_POS_CENTER) #self.window.connect("destroy", lambda w: gtk.main_quit()) #self.window.connect('delete_event', self.exit) self.set_title('Execute') vbox = gtk.VBox() self.cmd1, self.cmd2 = pack(vbox, [gtk.Entry(23),gtk.Entry(23)]) self.cmd1.connect('activate', self.execute) self.cmd2.connect('activate', self.execute) self.selected = gtk.CheckButton('Only selected atoms') pack(vbox, self.selected) self.add(vbox) vbox.show() self.show() self.gui = gui
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 __init__(self, gui): gtk.Window.__init__(self) self.set_position(gtk.WIN_POS_NONE) self.connect('destroy', self.close) #self.connect('delete_event', self.exit2) self.set_title('Movie') vbox = gtk.VBox() pack(vbox, gtk.Label(_('Image number:'))) self.frame_number = gtk.Adjustment(gui.frame, 0, gui.images.nimages - 1, 1.0, 5.0) self.frame_number.connect('value-changed', self.new_frame) hscale = pack(vbox, gtk.HScale(self.frame_number)) hscale.set_update_policy(gtk.UPDATE_DISCONTINUOUS) hscale.set_digits(0) buttons = [gtk.Button(stock=gtk.STOCK_GOTO_FIRST), gtk.Button(stock=gtk.STOCK_GO_BACK), gtk.Button(stock=gtk.STOCK_GO_FORWARD), gtk.Button(stock=gtk.STOCK_GOTO_LAST)] for button in buttons: hboxb = button.child.child label = hboxb.get_children()[1] hboxb.remove(label) buttons[0].connect('clicked', self.click, -10000000) buttons[1].connect('clicked', self.click, -1) buttons[2].connect('clicked', self.click, 1) buttons[3].connect('clicked', self.click, 10000000) pack(vbox, buttons) play, stop = pack(vbox, [gtk.Button(_('Play')), gtk.Button('Stop')]) play.connect('clicked', self.play) stop.connect('clicked', self.stop) self.rock = pack(vbox, gtk.CheckButton('Rock')) self.time = gtk.Adjustment(2.0, 0.5, 9.0, 0.2) hscale = pack(vbox, gtk.HScale(self.time)) hscale.set_update_policy(gtk.UPDATE_DISCONTINUOUS) self.time.connect('value-changed', self.new_time) self.add(vbox) self.set_tip = gtk.Tooltips().set_tip self.set_tip(hscale, _('Adjust play time.')) vbox.show() self.show() self.gui = gui #gui.m=self self.direction = 1 self.id = None
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 __init__(self, gui): gtk.Window.__init__(self) self.set_title(_('DFT')) vbox = gtk.VBox() combo = gtk.combo_box_new_text() self.xcfuncs = 'None LDA PBE revPBE RPBE PW91 EXX PBE0'.split() for xc in self.xcfuncs: combo.append_text(xc) pack(vbox, [gtk.Label(_('XC-functional: ')), combo]) button = radio(None, monkhorstpack) button = radio(button, special) pack(vbox, gtk.Label(_('Repeat atoms:'))) self.kpts = [gtk.Adjustment(r, 1, 99, 1) for r in gui.atoms.repeat] pack(vbox, [gtk.SpinButton(r, 0, 0) for r in self.repeat]) for r in self.repeat: r.connect('value-changed', self.change) close = pack(vbox, gtk.Button(_('Close'))) close.connect('clicked', lambda widget: self.destroy()) self.add(vbox) vbox.show() self.show() self.gui = gui xc = gui.atoms.dft.get('xc', 'None') combo.set_active(self.xcfuncs.index(xc))
def __init__(self, gui): gtk.Window.__init__(self) angles = irotate(gui.axes) self.set_title('Rotate') vbox = gtk.VBox() pack(vbox, gtk.Label('Rotation angles:')) self.rotate = [ gtk.Adjustment(value=a, lower=-360, upper=360, step_incr=1, page_incr=10) for a in angles ] pack(vbox, [gtk.SpinButton(a, climb_rate=0, digits=1) for a in self.rotate]) for r in self.rotate: r.connect('value-changed', self.change) button = pack(vbox, gtk.Button('Update')) button.connect('clicked', self.update_angles) pack( vbox, gtk.Label('Note:\nYou can rotate freely\n' 'with the mouse, by holding\n' 'down mouse botton 2.')) self.add(vbox) vbox.show() self.show() self.gui = gui
def __init__(self, gui): gtk.Window.__init__(self) self.set_title(_('DFT')) vbox = gtk.VBox() combo = gtk.combo_box_new_text() self.xcfuncs = 'None LDA PBE revPBE RPBE PW91 EXX PBE0'.split() for xc in self.xcfuncs: combo.append_text(xc) pack(vbox, [gtk.Label(_('XC-functional: ')), combo]) button=radio(None,monkhorstpack) button=radio(button, special) pack(vbox, gtk.Label(_('Repeat atoms:'))) self.kpts = [gtk.Adjustment(r, 1, 99, 1) for r in gui.atoms.repeat] pack(vbox, [gtk.SpinButton(r, 0, 0) for r in self.repeat]) for r in self.repeat: r.connect('value-changed', self.change) close = pack(vbox, gtk.Button(_('Close'))) close.connect('clicked', lambda widget: self.destroy()) self.add(vbox) vbox.show() self.show() self.gui = gui xc = gui.atoms.dft.get('xc', 'None') combo.set_active(self.xcfuncs.index(xc))
def open(self, button=None): from ase.io.formats import all_formats, get_ioformat formats = [(_('Automatic'), None)] def key(item): return item[1][0] for format, (description, code) in sorted(all_formats.items(), key=key): io = get_ioformat(format) if io.read and description != '?': formats.append((_(description), format)) chooser = gtk.FileChooserDialog( _('Open ...'), None, gtk.FILE_CHOOSER_ACTION_OPEN, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK)) chooser.set_filename(_("<<filename>>")) # Add a file type filter name_to_format = {} types = gtk.combo_box_new_text() for name, format in formats: types.append_text(name) name_to_format[name] = format types.set_active(0) img_vbox = gtk.VBox() pack(img_vbox, [gtk.Label(_('File type:')), types]) img_vbox.show() chooser.set_extra_widget(img_vbox) ok = chooser.run() == gtk.RESPONSE_OK if ok: filenames = [chooser.get_filename()] filetype = types.get_active_text() chooser.destroy() if not ok: return self.reset_tools_modes() self.images.read(filenames, slice(None), name_to_format[filetype]) self.set_colors() self.set_coordinates(self.images.nimages - 1, focus=True)
def __init__(self, gui): gtk.Window.__init__(self) self.set_title(_('Constraints')) vbox = gtk.VBox() b = pack(vbox, [gtk.Button(_('Constrain')), gtk.Label(_(' selected atoms'))])[0] b.connect('clicked', self.selected) b = pack(vbox, [gtk.Button(_('Constrain')), gtk.Label(_(' immobile atoms:'))])[0] b.connect('clicked', self.immobile) b = pack(vbox, gtk.Button('Clear constraints')) b.connect('clicked', self.clear) close = pack(vbox, gtk.Button(_('Close'))) close.connect('clicked', lambda widget: self.destroy()) self.add(vbox) vbox.show() self.show() self.gui = gui
def __init__(self, gui): gtk.Window.__init__(self) self.set_title(_("Quick Info")) vbox = gtk.VBox() images = gui.images if images.natoms < 1: txt = _("No atoms loaded.") else: (nimg, natoms, three) = images.P.shape assert three == 3 img = gui.frame uc = images.A[img] if nimg > 1: equal = True for i in range(nimg): equal = equal and (uc == images.A[i]).all() if equal: uctxt = ucconst else: uctxt = ucvaries else: uctxt = "" if nimg == 1: imgtxt = singleimage else: imgtxt = multiimage % (img, nimg - 1) periodic = [[_('no'), _('yes')][periodic] for periodic in images.pbc] # TRANSLATORS: This has the form Periodic: no, no, yes pbcstring = _('Periodic: %s, %s, %s') % tuple(periodic) txt = format % ((imgtxt, natoms) + tuple(uc.flat) + (pbcstring,) + (uctxt,)) label = gtk.Label(txt) pack(vbox, [label]) but = gtk.Button(stock=gtk.STOCK_CLOSE) but.connect('clicked', self.close) pack(vbox, [but], end=True) self.add(vbox) vbox.show() self.show() self.gui = gui
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.images.Z[n]] name = formula(Z) if (box_selection == selection).all(): name += ': ' + self.texture_selection.get_text() texture_button = gtk.combo_box_new_text() for t in self.finish_list: texture_button.append_text(t) texture_button.set_active(1) transparency = gtk.Adjustment(0, 0.0, 1.0, 0.01) transparency_spin = gtk.SpinButton(transparency, 0, 0) transparency_spin.set_digits(2) delete_button = gtk.Button(stock=gtk.STOCK_DELETE) alignment = delete_button.get_children()[0] index = len(self.materials) delete_button.connect("clicked", self.delete_material, {"n": index}) self.materials += [[ True, selection, texture_button, gtk.Label(_(" transparency: ")), transparency_spin, gtk.Label(" "), delete_button, gtk.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: oops( _("Can not create new texture! Must have some atoms selected to create a new material!" ))
def update_direction_table(self): "Update the part of the GUI containing the table of directions." #Discard old table oldwidgets = self.direction_table_box.get_children() assert len(oldwidgets) == 1 oldwidgets[0].hide() self.direction_table_box.remove(oldwidgets[0]) del oldwidgets # It should now be gone tbl = gtk.Table(len(self.direction_table)+1, 7) pack(self.direction_table_box, [tbl]) for i, data in enumerate(self.direction_table): tbl.attach(gtk.Label("%s: " % (str(data[0]),)), 0, 1, i, i+1) if self.method.get_active(): # Wulff construction spin = gtk.SpinButton(data[2], 1.0, 3) else: # Layers spin = gtk.SpinButton(data[1], 1, 0) tbl.attach(spin, 1, 2, i, i+1) tbl.attach(gtk.Label(" "), 2, 3, i, i+1) but = gtk.Button(_("Up")) but.connect("clicked", self.row_swap_next, i-1) if i == 0: but.set_sensitive(False) tbl.attach(but, 3, 4, i, i+1) but = gtk.Button(_("Down")) but.connect("clicked", self.row_swap_next, i) if i == len(self.direction_table)-1: but.set_sensitive(False) tbl.attach(but, 4, 5, i, i+1) but = gtk.Button(_("Delete")) but.connect("clicked", self.row_delete, i) if len(self.direction_table) == 1: but.set_sensitive(False) tbl.attach(but, 5, 6, i, i+1) tbl.show_all() self.update()
def makeoutputfield(self, box, label=_("Output:"), heading=None): frame = gtk.Frame(label) if box is not None: box.pack_start(frame, True, True, 0) box2 = gtk.VBox() frame.add(box2) if heading is not None: pack(box2, [gtk.Label(heading)]) scrwin = gtk.ScrolledWindow() scrwin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.output = gtk.TextBuffer() txtview = gtk.TextView(self.output) txtview.set_editable(False) scrwin.add(txtview) scrwin.show_all() box2.pack_start(scrwin, True, True, 0) self.savebutton = gtk.Button(stock=gtk.STOCK_SAVE) self.savebutton.connect('clicked', self.saveoutput) self.savebutton.set_sensitive(False) pack(box2, [self.savebutton]) box2.show() frame.show() return frame
def packtext(self, vbox, text, label=None): "Pack an text frame into the window." pack(vbox, gtk.Label("")) txtframe = gtk.Frame(label) txtlbl = gtk.Label(text) txtframe.add(txtlbl) txtlbl.show() pack(vbox, txtframe) pack(vbox, gtk.Label(""))
def __init__(self): DefaultProgressIndicator.__init__(self) # GPAW progress frame self.gpawframe = gtk.Frame("GPAW progress:") vbox = self.gpawvbox = gtk.VBox() self.gpawframe.add(vbox) self.table = gtk.Table(1, 2) self.tablerows = 0 pack(vbox, self.table) self.status = gtk.Label("-") self.tablepack([gtk.Label(_("Status: ")), self.status]) self.iteration = gtk.Label("-") self.tablepack([gtk.Label(_("Iteration: ")), self.iteration]) self.tablepack([gtk.Label("")]) lbl = gtk.Label() lbl.set_markup(_("log<sub>10</sub>(change):")) self.tablepack([gtk.Label(""), lbl]) self.wfs_progress = gtk.ProgressBar() self.tablepack([gtk.Label(_("Wave functions: ")), self.wfs_progress]) self.dens_progress = gtk.ProgressBar() self.tablepack([gtk.Label(_("Density: ")), self.dens_progress]) self.energy_progress = gtk.ProgressBar() self.tablepack([gtk.Label(_("Energy: ")), self.energy_progress]) self.tablepack([gtk.Label("")]) self.versionlabel = gtk.Label("") self.tablepack([gtk.Label(_("GPAW version: ")), self.versionlabel]) self.natomslabel = gtk.Label("") self.tablepack([gtk.Label(_("Number of atoms: ")), self.natomslabel]) self.memorylabel = gtk.Label(_("N/A")) self.tablepack([gtk.Label(_("Memory estimate: ")), self.memorylabel]) self.globalbox.pack_start(self.gpawframe) self.gpawframe.show() vbox.show() self.active = False
def add_basis_atom(self, *args): """ add an atom to the customizable basis """ n = len(self.elements) self.elements += [[ gtk.Entry(max=3), gtk.Entry(max=8), gtk.Entry(max=8), gtk.Entry(max=8), gtk.Label('\t\t\t'), gtk.Label('\tx: '), gtk.Label(' y: '), gtk.Label(' z: '), gtk.Label(' '), gtk.Button(stock=gtk.STOCK_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): gtk.Window.__init__(self) self.set_title("Quick Info") vbox = gtk.VBox() images = gui.images if images.natoms < 1: txt = "No atoms loaded." else: (nimg, natoms, three) = images.P.shape assert three == 3 img = gui.frame uc = images.A[img] if nimg > 1: equal = True for i in range(nimg): equal = equal and (uc == images.A[i]).all() if equal: uctxt = ucconst else: uctxt = ucvaries else: uctxt = "" if nimg == 1: imgtxt = singleimage else: imgtxt = multiimage % (img, nimg-1) txt = format % ((imgtxt, natoms) + tuple(uc.flat) + (uctxt,)) label = gtk.Label(txt) pack(vbox, [label]) but = gtk.Button(stock=gtk.STOCK_CLOSE) but.connect('clicked', self.close) pack(vbox, [but], end=True) self.add(vbox) vbox.show() self.show() self.gui = gui
def __init__(self, gui): Simulation.__init__(self, gui) self.set_title(_("Potential energy and forces")) self.set_default_size(-1, 400) vbox = gtk.VBox() self.packtext(vbox, _("Calculate potential energy and the force on all " "atoms")) self.packimageselection(vbox) pack(vbox, gtk.Label("")) self.forces = gtk.CheckButton(_("Write forces on the atoms")) self.forces.set_active(True) pack(vbox, [self.forces]) pack(vbox, [gtk.Label("")]) self.makeoutputfield(vbox) pack(vbox, gtk.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 = gtk.VBox() self.packtext(vbox, "Calculate potential energy and the force on all atoms") self.packimageselection(vbox) pack(vbox, gtk.Label("")) self.forces = gtk.CheckButton("Write forces on the atoms") self.forces.set_active(True) pack(vbox, [self.forces]) pack(vbox, [gtk.Label("")]) self.makeoutputfield(vbox) pack(vbox, gtk.Label("")) self.makebutbox(vbox) vbox.show() self.add(vbox) self.show() self.gui.register_vulnerable(self)
def __init__(self, gui): gtk.Window.__init__(self) self.gui = gui self.set_title('Expert user mode') vbox = gtk.VBox() vbox.set_border_width(5) self.sw = gtk.ScrolledWindow() self.sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.textview = gtk.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 = gtk.Entry(60) self.cmd.connect('activate', self.execute) self.cmd.connect('key-press-event', self.update_command_buffer) pack(vbox, [gtk.Label('>>>'), self.cmd]) self.cmd_buffer = getattr(gui, 'expert_mode_buffer', ['']) self.cmd_position = len(self.cmd_buffer) - 1 self.selected = gtk.CheckButton('Only selected atoms (sa) ') self.selected.connect('toggled', self.selected_changed) self.images_only = gtk.CheckButton('Only current frame (cf) ') self.images_only.connect('toggled', self.images_changed) pack(vbox, [self.selected, self.images_only]) save_button = gtk.Button(stock=gtk.STOCK_SAVE) save_button.connect('clicked', self.save_output) help_button = gtk.Button(stock=gtk.STOCK_HELP) help_button.connect('clicked', self.terminal_help, "") pack(vbox, [ gtk.Label('Global: Use n, N, R, A, S, D, E, frame;' + ' Atoms: Use a, x, y, z, f, s, Z '), help_button, save_button ]) self.add(vbox) vbox.show() self.show() self.cmd.grab_focus()
def __init__(self, gui): gtk.Window.__init__(self) angles = irotate(gui.axes) self.set_title(_('Rotate')) vbox = gtk.VBox() pack(vbox, gtk.Label(_('Rotation angles:'))) self.rotate = [gtk.Adjustment(value=a, lower=-360, upper=360, step_incr=1, page_incr=10) for a in angles] pack(vbox, [gtk.SpinButton(a, climb_rate=0, digits=1) for a in self.rotate]) for r in self.rotate: r.connect('value-changed', self.change) button = pack(vbox, gtk.Button(_('Update'))) button.connect('clicked', self.update_angles) pack(vbox, gtk.Label(_('Note:\nYou can rotate freely\n' 'with the mouse, by holding\n' 'down mouse button 2.'))) self.add(vbox) vbox.show() self.show() self.gui = gui
def __init__(self, gui): Simulation.__init__(self, gui) self.set_title(_("Energy minimization")) vbox = gtk.VBox() self.packtext(vbox, _("Minimize the energy with respect to the positions.")) self.packimageselection(vbox) pack(vbox, gtk.Label("")) self.make_minimize_gui(vbox) pack(vbox, gtk.Label("")) self.status_label = gtk.Label("") pack(vbox, [self.status_label]) self.makebutbox(vbox) vbox.show() self.add(vbox) self.show() self.gui.register_vulnerable(self)
def __init__(self, title, time, code): gtk.Window.__init__(self) self.set_title(_("ag: Python code")) vbox = gtk.VBox() lbl = gtk.Label(fr1_template % dict(title=title, time=time)) lbl.set_alignment(0.0, 0.5) fr = gtk.Frame(_("Information:")) fr.add(lbl) pack(vbox, fr) txtbuf = gtk.TextBuffer() txtbuf.set_text(code) txtview = gtk.TextView(txtbuf) txtview.set_editable(False) fr = gtk.Frame(_("Python code:")) fr.add(txtview) fr.set_label_align(0.0, 0.5) pack(vbox, fr) but = gtk.Button(stock=gtk.STOCK_OK) but.connect('clicked', lambda x: self.destroy()) pack(vbox, [but], end=True, bottom=True) self.add(vbox) self.show_all()
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
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)
def __init__(self, gui): self.gui = gui gtk.Window.__init__(self) self.set_title(_('Render current view in povray ... ')) vbox = gtk.VBox() vbox.set_border_width(5) self.natoms = self.gui.images.natoms pack(vbox, [gtk.Label(_("Rendering %d atoms.") % self.natoms)]) self.size = [gtk.Adjustment(self.gui.width, 1, 9999, 50), gtk.Adjustment(self.gui.height, 1, 9999, 50)] self.width = gtk.SpinButton(self.size[0], 0, 0) self.height = gtk.SpinButton(self.size[1], 0, 0) self.render_constraints = gtk.CheckButton(_("Render constraints")) self.render_constraints.set_sensitive(not self.gui.images.dynamic.all()) self.render_constraints.connect("toggled",self.toggle_render_lines) pack(vbox, [gtk.Label(_("Width")), self.width, gtk.Label(_(" Height")), self.height, gtk.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 = gtk.SpinButton(gtk.Adjustment(0.07,0.01,9.99,0.01), 0, 0) self.line_width.set_digits(3) self.render_cell = gtk.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, [gtk.Label(_("Line width")), self.line_width, gtk.Label(_("Angstrom ")), self.render_cell]) pack(vbox, [gtk.Label("")]) filename = gui.window.get_title() len_suffix = len(filename.split('.')[-1])+1 if len(filename) > len_suffix: filename = filename[:-len_suffix] self.basename = gtk.Entry(max = 30) self.basename.connect("activate",self.set_outputname,"") self.basename.set_text(basename(filename)) set_name = gtk.Button(_("Set")) set_name.connect("clicked",self.set_outputname,"") pack(vbox,[gtk.Label(_("Output basename: ")), self.basename,set_name]) self.outputname = gtk.Label("") pack(vbox,[gtk.Label(_(" Filename: ")),self.outputname]) pack(vbox,[gtk.Label("")]) self.tbox = gtk.VBox() self.tbox.set_border_width(10) self.default_texture = gtk.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 = gtk.Adjustment(0,0.0,1.0,0.01) self.transparency = gtk.SpinButton(self.default_transparency, 0, 0) self.transparency.set_digits(2) pack(self.tbox,[gtk.Label(_(" Default texture for atoms: ")), self.default_texture, gtk.Label(_(" transparency: ")),self.transparency]) pack(self.tbox,[gtk.Label(_("Define atom selection for new texture:"))]) self.texture_selection = gtk.Entry(max = 50) self.texture_select_but = gtk.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 = gtk.Button(_("Create new texture from selection")) self.create_texture.connect("clicked",self.material_from_selection,"") self.selection_help_but = gtk.Button(_("Help on textures")) self.selection_help_but.connect("clicked",self.selection_help,"") self.materials = [] pack(self.tbox,[self.create_texture, gtk.Label(" "), self.selection_help_but]) pack(vbox,[self.tbox]) pack(vbox,[gtk.Label("")]) self.camera_style = gtk.combo_box_new_text() for c in self.cameras: self.camera_style.append_text(c) self.camera_style.set_active(0) self.camera_distance = gtk.SpinButton(gtk.Adjustment(50.0,-99.0,99.0,1.0), 0, 0) self.camera_distance.set_digits(1) pack(vbox,[gtk.Label(_("Camera type: ")),self.camera_style, gtk.Label(_(" Camera distance")),self.camera_distance]) self.single_frame = gtk.RadioButton(None,_("Render current frame")) self.nimages = self.gui.images.nimages self.iframe = self.gui.frame self.movie = gtk.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,gtk.Label(" "),self.movie]) self.transparent = gtk.CheckButton(_("Transparent background")) self.transparent.set_active(True) pack(vbox,[self.transparent]) self.run_povray = gtk.CheckButton(_("Run povray ")) self.run_povray.set_active(True) self.run_povray.connect("toggled",self.toggle_run_povray,"") self.keep_files = gtk.CheckButton(_("Keep povray files ")) self.keep_files.set_active(False) self.keep_files_status = True self.window_open = gtk.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,[gtk.Label("")]) cancel_but = gtk.Button(stock=gtk.STOCK_CANCEL) cancel_but.connect('clicked', lambda widget: self.destroy()) ok_but = gtk.Button(stock=gtk.STOCK_OK) ok_but.connect('clicked', self.ok) close_but = gtk.Button(stock=gtk.STOCK_CLOSE) close_but.connect('clicked', lambda widget: self.destroy()) butbox = gtk.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): 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()
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
def __init__(self, gui): gtk.Window.__init__(self) self.set_title('Settings') self.gui = gui vbox = gtk.VBox() # Constraints a = pack(vbox, gtk.Label()) a.set_markup('<span size="larger" underline="single">' '%s</span>' % _('Constraints:')) a, b = pack(vbox, [gtk.Button(_('Constrain')), gtk.Label('/'), gtk.Button(_('release')), gtk.Label(_(' selected atoms'))])[::2] a.connect('clicked', self.constrain_selected) b.connect('clicked', self.release_selected) a = pack(vbox, gtk.Button(_('Constrain immobile atoms'))) a.connect('clicked', self.immobile) a = pack(vbox, gtk.Button(_('Clear all constraints'))) a.connect('clicked', self.clear_constraints) # Visibility a = pack(vbox, gtk.Label()) a.set_markup('\n<span size="larger" underline="single">' '%s</span>' % _('Visibility:')) a, b = pack(vbox, [gtk.Button(_('Hide')), gtk.Label('/'), gtk.Button(_('show')), gtk.Label(_(' selected atoms'))])[::2] a.connect('clicked', self.hide_selected) b.connect('clicked', self.show_selected) a = pack(vbox, gtk.Button(_('View all atoms'))) a.connect('clicked', self.view_all) # Miscellaneous a = pack(vbox, gtk.Label()) a.set_markup('\n<span size="larger" underline="single">' '%s</span>' % _('Miscellaneous:')) self.scale = gtk.Adjustment(value=.89, lower=0.2, upper=2.0, step_incr=0.1, page_incr=0.5) pack(vbox, [gtk.Label(_('Scale atomic radii:')), gtk.SpinButton(self.scale, climb_rate=0, digits=2)]) self.scale.connect('value-changed', self.scale_radii) # A close button pack(vbox, gtk.Label(_('\n'))) close = pack(vbox, gtk.Button(_('Close'))) close.connect('clicked', lambda widget: self.destroy()) # Add elements and show frame self.add(vbox) vbox.show() self.show()
def __init__(self, gui): self.gui = gui gtk.Window.__init__(self) self.set_title(_('Render current view in povray ... ')) vbox = gtk.VBox() vbox.set_border_width(5) self.natoms = self.gui.images.natoms pack(vbox, [gtk.Label(_("Rendering %d atoms.") % self.natoms)]) self.size = [ gtk.Adjustment(self.gui.width, 1, 9999, 50), gtk.Adjustment(self.gui.height, 1, 9999, 50) ] self.width = gtk.SpinButton(self.size[0], 0, 0) self.height = gtk.SpinButton(self.size[1], 0, 0) self.render_constraints = gtk.CheckButton(_("Render constraints")) self.render_constraints.set_sensitive( not self.gui.images.dynamic.all()) self.render_constraints.connect("toggled", self.toggle_render_lines) pack(vbox, [ gtk.Label(_("Width")), self.width, gtk.Label(_(" Height")), self.height, gtk.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 = gtk.SpinButton( gtk.Adjustment(0.07, 0.01, 9.99, 0.01), 0, 0) self.line_width.set_digits(3) self.render_cell = gtk.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, [ gtk.Label(_("Line width")), self.line_width, gtk.Label(_("Angstrom ")), self.render_cell ]) pack(vbox, [gtk.Label("")]) filename = gui.window.get_title() len_suffix = len(filename.split('.')[-1]) + 1 if len(filename) > len_suffix: filename = filename[:-len_suffix] self.basename = gtk.Entry(max=30) self.basename.connect("activate", self.set_outputname, "") self.basename.set_text(basename(filename)) set_name = gtk.Button(_("Set")) set_name.connect("clicked", self.set_outputname, "") pack(vbox, [gtk.Label(_("Output basename: ")), self.basename, set_name]) self.outputname = gtk.Label("") pack(vbox, [gtk.Label(_(" Filename: ")), self.outputname]) pack(vbox, [gtk.Label("")]) self.tbox = gtk.VBox() self.tbox.set_border_width(10) self.default_texture = gtk.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 = gtk.Adjustment(0, 0.0, 1.0, 0.01) self.transparency = gtk.SpinButton(self.default_transparency, 0, 0) self.transparency.set_digits(2) pack(self.tbox, [ gtk.Label(_(" Default texture for atoms: ")), self.default_texture, gtk.Label(_(" transparency: ")), self.transparency ]) pack(self.tbox, [gtk.Label(_("Define atom selection for new texture:"))]) self.texture_selection = gtk.Entry(max=50) self.texture_select_but = gtk.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 = gtk.Button( _("Create new texture from selection")) self.create_texture.connect("clicked", self.material_from_selection, "") self.selection_help_but = gtk.Button(_("Help on textures")) self.selection_help_but.connect("clicked", self.selection_help, "") self.materials = [] pack(self.tbox, [ self.create_texture, gtk.Label(" "), self.selection_help_but ]) pack(vbox, [self.tbox]) pack(vbox, [gtk.Label("")]) self.camera_style = gtk.combo_box_new_text() for c in self.cameras: self.camera_style.append_text(c) self.camera_style.set_active(0) self.camera_distance = gtk.SpinButton( gtk.Adjustment(50.0, -99.0, 99.0, 1.0), 0, 0) self.camera_distance.set_digits(1) pack(vbox, [ gtk.Label(_("Camera type: ")), self.camera_style, gtk.Label(_(" Camera distance")), self.camera_distance ]) self.single_frame = gtk.RadioButton(None, _("Render current frame")) self.nimages = self.gui.images.nimages self.iframe = self.gui.frame self.movie = gtk.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, gtk.Label(" "), self.movie]) self.transparent = gtk.CheckButton(_("Transparent background")) self.transparent.set_active(True) pack(vbox, [self.transparent]) self.run_povray = gtk.CheckButton(_("Run povray ")) self.run_povray.set_active(True) self.run_povray.connect("toggled", self.toggle_run_povray, "") self.keep_files = gtk.CheckButton(_("Keep povray files ")) self.keep_files.set_active(False) self.keep_files_status = True self.window_open = gtk.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, [gtk.Label("")]) cancel_but = gtk.Button(stock=gtk.STOCK_CANCEL) cancel_but.connect('clicked', lambda widget: self.destroy()) ok_but = gtk.Button(stock=gtk.STOCK_OK) ok_but.connect('clicked', self.ok) close_but = gtk.Button(stock=gtk.STOCK_CLOSE) close_but.connect('clicked', lambda widget: self.destroy()) butbox = gtk.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): # Set defaults self.log_file = None self.fchk_file = None self.coords = None self.scaling_method = "global" # Set up window gtk.Window.__init__(self) self.set_title("Level Diagrams") self.gui = gui vbox = gtk.VBox() vbox.set_border_width(5) # Button to select G09 log file a = pack(vbox, gtk.Label()) self.log_entry_box, b = pack(vbox, [gtk.Entry(max=25), gtk.Button(_("Choose Gaussian output file"))]) self.log_entry_box.set_max_length(0) self.log_entry_box.connect("activate", self.log_entry) b.connect("clicked", self.choose_log_file) # Button to select fchk file a = pack(vbox, gtk.Label()) self.fchk_entry_box, b = pack(vbox, [gtk.Entry(max=25), gtk.Button(_("Choose fchk file"))]) self.fchk_entry_box.set_max_length(0) self.fchk_entry_box.connect("activate", self.log_entry) b.connect("clicked", self.choose_fchk_file) # Dial to set number of occupied orbitals self.occ_scale = gtk.Adjustment(value=2, lower=0, upper=100, step_incr=1) self.occ_spinner = gtk.SpinButton(self.occ_scale, climb_rate=0, digits=0) self.occ_spinner.set_update_policy(gtk.UPDATE_IF_VALID) self.occ_spinner.set_numeric(True) pack(vbox, [gtk.Label(_("Plot ")), self.occ_spinner, gtk.Label(_("occupied states "))]) self.occ_scale.connect("value-changed", self.scale_occ_orb) # Dial to set number of virtual orbitals self.virt_scale = gtk.Adjustment(value=2, lower=0, upper=100, step_incr=1) self.virt_spinner = gtk.SpinButton(self.virt_scale, climb_rate=0, digits=0) self.virt_spinner.set_update_policy(gtk.UPDATE_IF_VALID) self.virt_spinner.set_numeric(True) pack(vbox, [gtk.Label(_("Plot ")), self.virt_spinner, gtk.Label(_("unoccupied states "))]) self.virt_scale.connect("value-changed", self.scale_virt_orb) # Dial to set number of bins self.bin_scale = gtk.Adjustment(value=0.3, lower=0.3, upper=0.5, step_incr=0.05) self.bin_spinner = gtk.SpinButton(self.bin_scale, climb_rate=0.05, digits=2) self.bin_spinner.set_update_policy(gtk.UPDATE_IF_VALID) self.bin_spinner.set_numeric(True) pack(vbox, [gtk.Label(_(u"Grid spacing (\u212B) ")), self.bin_spinner]) pack(vbox, gtk.Label(_("Note that the grid spacing should be large compared to the width of the voxels."))) self.bin_scale.connect("value-changed", self.scale_bin_num) # Button to select atoms a = pack(vbox, gtk.Label()) a, b = pack(vbox, [gtk.Label(_("Select two points and click ")), gtk.Button(_("Confirm"))]) b.connect("clicked", self.confirm_points) # Button to set scaling a = pack(vbox, gtk.Label("Intensity scaling")) button = pack(vbox, gtk.RadioButton(None, "Global")) button.connect("toggled", self.set_scaling_method, "global") button.show() button = pack(vbox, gtk.RadioButton(button, "Orbital")) button.connect("toggled", self.set_scaling_method, "orbital") button.show() # Button to set all of the parameters a = pack(vbox, gtk.Label()) a = pack(vbox, gtk.Button(_("Run"))) a.connect("clicked", self.run_sold) # Add elements and show frame self.add(vbox) vbox.show() self.show()
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
def __init__(self): gtk.Window.__init__(self) self.set_title(_("Progress")) self.globalbox = gtk.VBox() self.nextupdate = 0 self.fmax_max = 1.0 # Scaling deformation progress frame self.scalebox = gtk.VBox() self.scaleframe = gtk.Frame(_("Scaling deformation:")) vbox = gtk.VBox() self.scaleframe.add(vbox) pack(self.scalebox, [self.scaleframe]) pack(self.scalebox, gtk.Label("")) self.label_scale_stepno_format = _("Step number %s of %s.") self.label_scale_stepno = gtk.Label( self.label_scale_stepno_format % ("-" , "-")) pack(vbox, [self.label_scale_stepno]) self.scale_progress = gtk.ProgressBar() self.scale_progress.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.color_parse('#00AA00')) pack(vbox, [self.scale_progress]) vbox.show() self.scaleframe.show() self.globalbox.pack_start(self.scalebox) # Minimization progress frame self.minbox = gtk.VBox() # Box containing frame and spacing self.minframe = gtk.Frame(_("Energy minimization:")) vbox = gtk.VBox() # Box containing the frames content. self.minframe.add(vbox) pack(self.minbox, [self.minframe]) pack(self.minbox, gtk.Label("")) self.label_min_stepno = gtk.Label("-") pack(vbox, [gtk.Label(_("Step number: ")), self.label_min_stepno]) lbl = gtk.Label() lbl.set_markup(_("F<sub>max</sub>: ")) self.minimize_progress = gtk.ProgressBar() pack(vbox, [lbl, self.minimize_progress]) self.label_min_fmax = gtk.Label("-") lbl = gtk.Label() lbl.set_markup(_("Convergence criterion: F<sub>max</sub> = ")) pack(vbox, [lbl, self.label_min_fmax]) self.label_min_maxsteps = gtk.Label("-") pack(vbox, [gtk.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 = gtk.Button(stock=gtk.STOCK_CANCEL) self.cancelbut.connect('clicked', self.cancel) pack(self.globalbox, [self.cancelbut], end=True, bottom=True)
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