Example #1
0
    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))
Example #2
0
    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)
Example #3
0
    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))
Example #4
0
    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
Example #5
0
 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 = []
Example #6
0
 def __init__(self, text):
     gtk.Window.__init__(self)
     vbox = gtk.VBox()
     self.add(vbox)
     label = pack(vbox, gtk.Label())
     label.set_line_wrap(True)
     text = _(text).replace('<c>', '<span foreground="blue">')
     text = text.replace('</c>', '</span>')
     label.set_markup(text)
     close = pack(vbox, gtk.Button(_('Close')))
     close.connect('clicked', lambda widget: self.destroy())
     self.show_all()
Example #7
0
 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
Example #8
0
    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
Example #9
0
 def __init__(self, menubar, name, items):
     self.items = {}
     menu = gtk.Menu()
     for data in items:
         text = data[0]
         callback = data[1]
         args = data[2:]
         menuitem = gtk.MenuItem(_(text))
         menu.append(menuitem)
         menuitem.connect('activate', callback, *args)
         menuitem.show()
         self.items[text] = menuitem
     menuitem = gtk.MenuItem(_(name))
     menubar.append(menuitem)
     menuitem.set_submenu(menu)
     menuitem.show()
Example #10
0
 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)
Example #11
0
 def __init__(self, menubar, name, items):
     self.items = {}
     menu = gtk.Menu()
     for data in items:
         text = data[0]
         callback = data[1]
         args = data[2:]
         menuitem = gtk.MenuItem(_(text))
         menu.append(menuitem)
         menuitem.connect('activate', callback, *args)
         menuitem.show()
         self.items[text] = menuitem
     menuitem = gtk.MenuItem(_(name))
     menubar.append(menuitem)
     menuitem.set_submenu(menu)
     menuitem.show()
Example #12
0
 def set_text(self, text):
     # Count line length
     linelen = max([len(x) for x in text.split('\n')])
     text = _(text).replace('<c>', '<span foreground="blue">')
     text = text.replace('</c>', '</span>')
     self.label.set_width_chars(linelen)
     self.label.set_line_wrap(False)
     self.label.set_markup(text)
Example #13
0
 def initialize(self, text):
     gtk.Window.__init__(self)
     self.set_title("Help")
     self._initialized = True
     vbox = gtk.VBox()
     self.add(vbox)
     self.label = pack(vbox, gtk.Label())
     self.label.set_line_wrap(True)
     self.set_text(text)
     close = gtk.Button(_('Close'))
     pack(vbox, [close])
     close.connect('clicked', self.destroy)
     self.connect("delete-event", self.destroy)
     self.show_all()
Example #14
0
 def save_output(self, *args):
     chooser = gtk.FileChooserDialog(_('Save Terminal text ...'), None,
                                     gtk.FILE_CHOOSER_ACTION_SAVE,
                                     (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                                      gtk.STOCK_SAVE, gtk.RESPONSE_OK))
     save = chooser.run()
     if save == gtk.RESPONSE_OK or save == gtk.RESPONSE_SAVE:
         filename = chooser.get_filename()
         text = self.textbuffer.get_text(self.textbuffer.get_start_iter(),
                                         self.textbuffer.get_end_iter())
         fd = open(filename, 'w')
         fd.write(text)
         fd.close()
         chooser.destroy()
Example #15
0
 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
Example #16
0
 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
Example #17
0
 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
Example #18
0
    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')
        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
Example #19
0
def help(text):
    button = gtk.Button(_('Help'))
    button.connect('clicked', lambda widget, text=text: Help(text))
    return button
Example #20
0
def help(text):
    button = gtk.Button(_('Help'))
    button.connect('clicked', lambda widget, text=text: Help(text))
    return button
Example #21
0
    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">'
                     'Constraints:</span>')
        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">'
                     'Visibility:</span>')
        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">'
                     'Miscellaneous:</span>')
        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()
Example #22
0
    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">'
                     'Constraints:</span>')
        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">'
                     'Visibility:</span>')
        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">'
                     'Miscellaneous:</span>')
        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()