(self, newAmount=0)
This method updates the progress bar
This method updates the progress bar
This method updates the progress bar
def update(self, newAmount=0):
        """
        This method updates the progress bar
        """

        if newAmount < self._min:
            newAmount = self._min
        elif newAmount > self._max:
            newAmount = self._max

        self._amount = newAmount

        # Figure out the new percent done, round to an integer
        diffFromMin = float(self._amount - self._min)
        percentDone = (diffFromMin / float(self._span)) * 100.0
        percentDone = round(percentDone)
        percentDone = min(100, int(percentDone))

        # Figure out how many hash bars the percentage should be
        allFull = self._width - len("100%% [] %s/%s  ETA 00:00" % (self._max, self._max))
        numHashes = (percentDone / 100.0) * allFull
        numHashes = int(round(numHashes))

        # Build a progress bar with an arrow of equal signs
        if numHashes == 0:
            self._progBar = "[>%s]" % (" " * (allFull - 1))
        elif numHashes == allFull:
            self._progBar = "[%s]" % ("=" * allFull)
        else:
            self._progBar = "[%s>%s]" % ("=" * (numHashes - 1),
                                          " " * (allFull - numHashes))

        # Add the percentage at the beginning of the progress bar
        percentString = getUnicode(percentDone) + "%"
        self._progBar = "%s %s" % (percentString, self._progBar)
def update ( self , newAmount = 0 ) : if newAmount < self . _min : newAmount = self . _min elif newAmount > self . _max : newAmount = self . _max self . _amount = newAmount # Figure out the new percent done, round to an integer diffFromMin = float ( self . _amount - self . _min ) percentDone = ( diffFromMin / float ( self . _span ) ) * 100.0 percentDone = round ( percentDone ) percentDone = min ( 100 , int ( percentDone ) ) # Figure out how many hash bars the percentage should be allFull = self . _width - len ( "100%% [] %s/%s  ETA 00:00" % ( self . _max , self . _max ) ) numHashes = ( percentDone / 100.0 ) * allFull numHashes = int ( round ( numHashes ) ) # Build a progress bar with an arrow of equal signs if numHashes == 0 : self . _progBar = "[>%s]" % ( " " * ( allFull - 1 ) ) elif numHashes == allFull : self . _progBar = "[%s]" % ( "=" * allFull ) else : self . _progBar = "[%s>%s]" % ( "=" * ( numHashes - 1 ) , " " * ( allFull - numHashes ) ) # Add the percentage at the beginning of the progress bar percentString = getUnicode ( percentDone ) + "%" self . _progBar = "%s %s" % ( percentString , self . _progBar )