()
Update progress bar range and value with currDID, totalCount[] and doneCount[]
Update progress bar range and value with currDID, totalCount[] and doneCount[]
Update progress bar range and value with currDID totalCount [] and doneCount []
def updatePB() -> None:
    """Update progress bar range and value with currDID, totalCount[] and doneCount[]"""
    if useOldAnkiAPI:
        # With old API, counts don't include cards in child decks
        if currDID:  # in a specific deck
            deckName = mw.col.decks.name(currDID)
            pbMax = pbValue = 0
            # Sum up all children decks
            for deckProp in mw.col.sched.deckDueList():
                name = deckProp[0]
                did = deckProp[1]
                if name.startswith(deckName):
                    pbMax += totalCount[did]
                    pbValue += doneCount[did]
        else:  # at desk browser
            pbMax = sum(totalCount.values())
            pbValue = sum(doneCount.values())
    else:
        # With new API, counts include cards in child decks
        if currDID:  # in a specific deck
            pbMax = totalCount[currDID]
            pbValue = doneCount[currDID]
        else:  # at desk browser
            pbMax = pbValue = 0
            # Sum top-level decks
            for node in mw.col.sched.deck_due_tree().children:
                pbMax += totalCount[node.deck_id]
                pbValue += doneCount[node.deck_id]

    # showInfo("pbMax = %d, pbValue = %d" % (pbMax, pbValue))

    if pbMax == 0:  # 100%
        progressBar.setRange(0, 1)
        progressBar.setValue(1)
    else:
        progressBar.setRange(0, pbMax)
        progressBar.setValue(pbValue)

    if showNumber:
        if showPercent:
            percent = 100 if pbMax == 0 else int(100 * pbValue / pbMax)
            progressBar.setFormat("%d / %d (%d%%)" % (pbValue, pbMax, percent))
        else:
            progressBar.setFormat("%d / %d" % (pbValue, pbMax))
    nmApplyStyle()
def updatePB ( ) -> None : if useOldAnkiAPI : # With old API, counts don't include cards in child decks if currDID : # in a specific deck deckName = mw . col . decks . name ( currDID ) pbMax = pbValue = 0 # Sum up all children decks for deckProp in mw . col . sched . deckDueList ( ) : name = deckProp [ 0 ] did = deckProp [ 1 ] if name . startswith ( deckName ) : pbMax += totalCount [ did ] pbValue += doneCount [ did ] else : # at desk browser pbMax = sum ( totalCount . values ( ) ) pbValue = sum ( doneCount . values ( ) ) else : # With new API, counts include cards in child decks if currDID : # in a specific deck pbMax = totalCount [ currDID ] pbValue = doneCount [ currDID ] else : # at desk browser pbMax = pbValue = 0 # Sum top-level decks for node in mw . col . sched . deck_due_tree ( ) . children : pbMax += totalCount [ node . deck_id ] pbValue += doneCount [ node . deck_id ] # showInfo("pbMax = %d, pbValue = %d" % (pbMax, pbValue)) if pbMax == 0 : # 100% progressBar . setRange ( 0 , 1 ) progressBar . setValue ( 1 ) else : progressBar . setRange ( 0 , pbMax ) progressBar . setValue ( pbValue ) if showNumber : if showPercent : percent = 100 if pbMax == 0 else int ( 100 * pbValue / pbMax ) progressBar . setFormat ( "%d / %d (%d%%)" % ( pbValue , pbMax , percent ) ) else : progressBar . setFormat ( "%d / %d" % ( pbValue , pbMax ) ) nmApplyStyle ( )