How to use progress bar #2706
-
|
I have tried to make progress bar for invoke_long_callback function. Here is my code that updates the progress variable calculus_progess. Unfortunatelly the UI dosen't get updated. I have added manual refresh, broadcast and add_shared_variable with no luck. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Hello! This is a great opportunity to try out the new "asynx" syntax for long callbacks which was made available in Taipy 4.1: import time
import taipy.gui.builder as tgb
from taipy.gui import Gui, State
calculus_progress = 0
async def start_progress(state: State):
for i in range(11):
state.calculus_progress = 10 * i
time.sleep(1)
with tgb.Page() as page:
tgb.progress("{calculus_progress}", show_value=True, title="Calculus Progress")
tgb.button("Start", on_action=start_progress)
if __name__ == "__main__":
pages = {"/": page}
gui = Gui(pages=pages)
# This will make the "calculus_progress" value be shared with all connected sessions/browsers
# gui.add_shared_variable("calculus_progress")
gui.run(title="Progress")You just need the declare the callback function as a coroutine (with If you are on an older version or just specifically need to use the Thanks for raising this discussion -- we need to document this feature. Feel free to close this discussion if it answers your question. |
Beta Was this translation helpful? Give feedback.
Hello! This is a great opportunity to try out the new "asynx" syntax for long callbacks which was made available in Taipy 4.1: