How do I implement a progress bar

后端 未结 5 400
遇见更好的自我
遇见更好的自我 2020-12-24 08:19

How do I implement a progress bar in jupyter-notebook?

I\'ve done this:

count = 0
max_count = 100
bar_width = 40
while count <= max_count:
    tim         


        
5条回答
  •  再見小時候
    2020-12-24 08:37

    Here is a solution (following this).

    from ipywidgets import IntProgress
    from IPython.display import display
    import time
    
    max_count = 100
    
    f = IntProgress(min=0, max=max_count) # instantiate the bar
    display(f) # display the bar
    
    count = 0
    while count <= max_count:
        f.value += 1 # signal to increment the progress bar
        time.sleep(.1)
        count += 1
    

    If the value that's changing in the loop is a float instead of an int, you can use ipwidgets.FloatProgress instead.

提交回复
热议问题