I found a workaround with add_next_tick_callback.
2 functions that are being called for each process
def progress_load(Percentage=1):
Perc = str(Percentage)
return f"""<div id="myProgress" style="width: 500px; background-color: grey;">
<div id="myBar" style="width: {Perc}%; height: 30px; background-color: green;"><b>{Perc}%</b></div>
</div>"""
def progress(Text,Percentage):
if Text != "COMPLETED":
progress_text_div.text = f'<b style="background-color: red; padding: 5px;">{Text}</b><br>'
progress_bar_div.text = progress_load(Percentage)
videoButton.button_type = 'danger'
videoButton.label = "PLEASE WAIT..."
else:
progress_text_div.text = f'<b style="background-color: green; padding: 5px;">{Text}</b><br>'
progress_bar_div.text = progress_load(Percentage)
videoButton.button_type = 'success'
videoButton.label = "CREATE VIDEO"
The 2 processes that needs to be kept up
def process_images_callback():
# Define the range of images for the video
imgRange = [int(rangeslider.value[0]), int(rangeslider.value[1])]
processImages(rootURL, rootDir, testDir, imageFileList, imgList, imHeight,
imWidth, imgRange, roi_x0, roi_y0, roi_x1, roi_y1, timeBetweenFrames,
checkbox_group.active)
# Task 2: Create Video
def create_video_callback():
#creating a Time stamp
timeStamp = datetime.now().strftime("%d%b%Y_%H%M%S")
if ((1 in checkbox_group.active) or (0 in checkbox_group.active)):
createVideoWithFFmpeg(ffmpegExe, videoFPSinput.value, 'video' + timeStamp + '.mp4', rootURL, testDir, timeStamp)
Lastly the function that calls everything with add_next_tick_callback.
def button_clicked():
curdoc().add_next_tick_callback(lambda: progress("STARTING", 1))
time.sleep(1)
curdoc().add_next_tick_callback(process_images_callback)
curdoc().add_next_tick_callback(lambda: progress("almost done", 30))
curdoc().add_next_tick_callback(create_video_callback)
curdoc().add_next_tick_callback(lambda: updateLayout(rootDir, rootURL,testDir, layout))
print("completed")
curdoc().add_next_tick_callback(lambda: progress("COMPLETED",100))
I don’t know if it is the best way to go about it but it works ig. Thanks for the help btw