def update_new_direction_and_size_stuff(self): if self.needs_4index[self.structure.value]: n = 4 else: n = 3 rows = self.new_direction_and_size_rows rows.clear() self.new_direction = row = ['('] for i in range(n): if i > 0: row.append(',') row.append(ui.SpinBox(0, -100, 100, 1)) row.append('):') if self.method.value == 'wulff': row.append(ui.SpinBox(1.0, 0.0, 1000.0, 0.1)) else: row.append(ui.SpinBox(5, 1, 100, 1)) row.append(ui.Button(_('Add'), self.row_add)) rows.add(row) if self.method.value == 'wulff': # Extra widgets for the Wulff construction self.size_radio = ui.RadioButtons( [_('Number of atoms'), _('Diameter')], ['natoms', 'diameter'], self.update_gui_size) self.size_natoms = ui.SpinBox(100, 1, 100000, 1, self.update_size_natoms) self.size_diameter = ui.SpinBox(5.0, 0, 100.0, 0.1, self.update_size_diameter) self.round_radio = ui.RadioButtons( [_('above '), _('below '), _('closest ')], ['above', 'below', 'closest'], callback=self.update) self.smaller_button = ui.Button(_('Smaller'), self.wulff_smaller) self.larger_button = ui.Button(_('Larger'), self.wulff_larger) rows.add(_('Choose size using:')) rows.add(self.size_radio) rows.add( [_('atoms'), self.size_natoms, _(u'ų'), self.size_diameter]) rows.add( _('Rounding: If exact size is not possible, choose the size:')) rows.add(self.round_radio) rows.add([self.smaller_button, self.larger_button]) self.update_gui_size() else: self.smaller_button = None self.larger_button = None
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 __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 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 __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.povray_executable = ui.Entry(width=30,value='povray') win.add([ui.Label(_('POVRAY executable')), self.povray_executable]) 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))