2017-01-26 16 views

回答

1

我发现了一个适用于我的解决方案,我也意识到我需要该过程在后台工作。

我首先必须使部件: jupyter nbextension使--py --sys前缀widgetsnbextension

from IPython.display import display 
from ipywidgets import Label 
from time import sleep 

import threading 

class App(object): 
    def __init__(self, nloops=2000): 
     self.nloops = nloops 
     self.pb = Label(description='Thread loops', value="0") 

    def start(self): 
     display(self.pb) 
     for i in range(10): 
      self.pb.value += str(i) 
      sleep(1) 

app = App(nloops=20000) 

t = threading.Thread(target=app.start) 

t.start() 

相关问题