Я могу создать анимированный знак загрузки, пока выполняется мой длинный код, однако мне бы хотелось, чтобы он отображался в Panel на развернутом GUI, который я создал.
Вот код это показывает анимированный знак загрузки в виде текста в блокноте Jupyter. Как мне затем развернуть его, чтобы активно показывать анимацию на панели?
# Define your process.
# Here is an example of the process function:
def the_process_function():
n = 7
for i in range(n):
time.sleep(1)
sys.stdout.write('\r'+'loading... process '+str(i)+'/'+str(n)+' '+ '{:.2f}'.format(i/n*100)+'%')
sys.stdout.flush()
sys.stdout.write('\r'+'loading... finished \n')
# Define your animated characters function:
def animated_loading():
chars = "/—\|"
for char in chars:
sys.stdout.write('\r'+'loading...'+char)
time.sleep(.1)
sys.stdout.flush()
# define name dan target of your thread
the_process = threading.Thread(name='process', target=the_process_function)
# start the thread
the_process.start()
# while the process is alive, call the animated_loading() function
while the_process.isAlive():
animated_loading()