コード例 #1
0
ファイル: utils.py プロジェクト: BackupTheBerlios/useless-svn
class DownloadStatus(VBox):
    def __init__(self, url, path):
        VBox.__init__(self)
        self.label = Label(path)
        self.label.show()
        self.pack_start(self.label, FALSE, FALSE, 0)
        self.pbar = ProgressBar()
        self.pack_end(self.pbar, FALSE, FALSE, 0)
        self.pbar.show()
        self.show()
        self._done = 0
        # self.thread = DownloadThread(url, path, self.progress)
        self.thread = DownloadThread(url, path, self.progress)
        # self.button = Button('start')
        # self.button.connect('clicked', self.start)
        # self.button.show()
        # self.pack_end(self.button, FALSE, FALSE, 0)
        self._started = False

    def progress(self, dt, dd, ut, ud):
        threads_enter()
        print "in progress", dt, dd, ut, ud
        if dt == 0:
            self._done += 0.1
            if self._done >= 1:
                self._done = 0
        else:
            self._done = float(dd) / float(dt)
        print "_done", self._done
        self.pbar.set_fraction(self._done)
        threads_leave()

    def start(self, *args):
        if not self._started:
            self.thread.start()
            self._started = True
コード例 #2
0
ファイル: utils.py プロジェクト: BackupTheBerlios/useless-svn
 def __init__(self, url, path):
     VBox.__init__(self)
     self.label = Label(path)
     self.label.show()
     self.pack_start(self.label, FALSE, FALSE, 0)
     self.pbar = ProgressBar()
     self.pack_end(self.pbar, FALSE, FALSE, 0)
     self.pbar.show()
     self.show()
     self._done = 0
     # self.thread = DownloadThread(url, path, self.progress)
     self.thread = DownloadThread(url, path, self.progress)
     # self.button = Button('start')
     # self.button.connect('clicked', self.start)
     # self.button.show()
     # self.pack_end(self.button, FALSE, FALSE, 0)
     self._started = False