In [ ]:
from __future__ import print_function
import time
import datetime
import threading
from IPython.display import display
from ipywidgets import widgets
In [ ]:
def display_dt(duration=5, widget=None, print_dt=False):
"""
display current time for duration (s)
"""
time_0 = time.time()
while time.time() < time_0 + duration:
dt = datetime.datetime.now().isoformat()
if print_dt:
print ("\r{}".format(dt), end="")
if widget is not None:
widget.value = dt
time.sleep(0.1)
return
display_dt(print_dt=True)
In [ ]:
w = widgets.Text()
w.value = "Hello"
display(w)
In [ ]:
t = threading.Thread(target=display_dt, args=(30,w))
t.start()
In [ ]:
for m in range(100000):
print ("\r{}".format(m), end="")
In [ ]:
assert False
In [ ]:
%%javascript
$('div.widget-area button.close:visible').click();
In [ ]: