Пример #1
0
    def next(self):
        # update progress bar
        self.bar.set_fraction( (self.index+1) / float(self.maxindex) )
        self.bar.set_text("")
        while gtk.events_pending():
            gtk.main_iteration()

        try:
            name = ProgressList.next(self)
        except StopIteration:
            self.stop_iteration()
            raise
        
        # update listview text
        if self.iter is None:
            self.iter = self.model.get_iter_first()
        else:
            self.iter = self.model.iter_next(self.iter)
        self.model.set_value( self.iter, 1, "IN PROGRESS" )
        self.bar.set_text(self.objects[self.index])        
        while gtk.events_pending():
            gtk.main_iteration()

        return name
Пример #2
0
    def __init__(self, objects):
        gtk.Window.__init__(self)
        self.set_modal(True)
        self.set_size_request(480,320)
        
        ProgressList.__init__(self, objects)

        vbox = gtk.VBox()

        # set up progressbar
        bar = gtk.ProgressBar()
        bar.set_fraction(0.0)
        bar.show()
        
        # set up listview with a model := (filename, status)
        model = gtk.ListStore(str, str)
        listview = gtk.TreeView(model)
        cell = gtk.CellRendererText()
        column = gtk.TreeViewColumn("filename", cell)
        column.set_cell_data_func(cell, self.render_filename)
        listview.append_column(column)
        column = gtk.TreeViewColumn('Status', cell, text=1)
        listview.append_column(column)
        listview.show()

        sw = uihelper.add_scrollbars(listview)
        sw.show()

        # the scrolled window (sw) with the listview is put into an expander widget
        expander = gtk.Expander("Details")
        expander.set_expanded(False)
        expander.add(sw)
        #expander.connect("notify::expanded", lambda e,p: self.check_resize())
        expander.show()

        # set up button box
        btn_cancel = gtk.Button(stock=gtk.STOCK_CANCEL)
        btn_cancel.show()

        btn_ok = gtk.Button(stock=gtk.STOCK_OK)
        btn_ok.show()
        
        btnbox = gtk.HButtonBox()
        btnbox.add(btn_cancel)
        btnbox.add(btn_ok)        
        btnbox.set_layout(gtk.BUTTONBOX_END)
        btnbox.show()

        # initially, btn_ok is disables.
        btn_cancel.connect("clicked", (lambda sender: self.abort()))

        btn_ok.connect("clicked", (lambda sender: self.destroy()))
        btn_ok.set_sensitive(False)        

        # stack everything into a vbox.
        #vbox.pack_start(listview, False, True, padding=5)
        vbox.pack_start(bar, False, True, padding=5)
        vbox.pack_start(expander, True, True, padding=5)
        vbox.pack_start(sw, True, True, padding=5)
        vbox.pack_end(btnbox,False,True, padding=5)
        vbox.show()
                
        self.add(vbox)
        self.show()

        # fill model with string names
        for object in self.objects:
            model.append( (object,"") )
        self.iter = None

        while gtk.events_pending():
            gtk.main_iteration()

        # save some variables for further reference
        self.model = model
        self.bar = bar
        self.btn_cancel = btn_cancel
        self.btn_ok = btn_ok
        self.expander = expander
Пример #3
0
 def abort(self):
     ProgressList.abort(self)
     self.model.set_value( self.iter, 1, "ABORTED" )
     self.expander.set_expanded(True)
     self.stop_iteration()