コード例 #1
0
ファイル: demo.py プロジェクト: Kwpolska/kwpbar.py
def demo():  # pragma: no cover
    """Run the demo."""
    if len(sys.argv) == 1:
        runs = 5
    else:
        runs = int(sys.argv[1])

    for i in range(0, runs + 1):
        kwpbar.pbar(i, runs)
        time.sleep(1)

    kwpbar.erase_pbar()
コード例 #2
0
def demo():  # pragma: no cover
    """Run the demo."""
    if len(sys.argv) == 1:
        runs = 5
    else:
        runs = int(sys.argv[1])

    for i in range(0, runs + 1):
        kwpbar.pbar(i, runs)
        time.sleep(1)

    kwpbar.erase_pbar()
コード例 #3
0
            # Find neighbors, in a very cheap way.
            neighbors = [
                (rownum-1, colnum),
                (rownum+1, colnum),
                (rownum, colnum-1),
                (rownum, colnum+1),
                (rownum-1, colnum-1),
                (rownum+1, colnum+1),
                (rownum-1, colnum+1),
                (rownum+1, colnum-1)
            ]
            # limit to numbers 0-100
            neighbors = [(i, j) for i, j in neighbors if i in range(100) and j in range(100)]
            neighbors_on = 0
            for nR, nC in neighbors:
                neighbors_on += NOW[nR][nC]

            # Determine new status of the current cell.
            if cell_on:
                NEXT[rownum][colnum] = (neighbors_on == 2 or neighbors_on == 3)
            else:
                NEXT[rownum][colnum] = (neighbors_on == 3)

        kwpbar.pbar((iteration * 100) + rownum, 100 * 100)
    NOW = NEXT
    # Part 2: four lights are stuck
    NOW[0][0] = NOW[99][0] = NOW[0][99] = NOW[99][99] = True

kwpbar.erase_pbar()
print(numpy.count_nonzero(NOW))
コード例 #4
0
ファイル: test_kwpbar.py プロジェクト: hottabxp/kwpbar.py
def test_erasing():
    """Test progressbar erasing."""
    kwpbar.pbar(2, 3)
    kwpbar.erase_pbar()