Path: blob/main/doc/tutorials/basic/progressive_layouts.md
2013 views
Update Progressively
Welcome to the "Update Progressively" tutorial! Here, we'll explore an exciting aspect of HoloViz Panel: progressively updating content while running a slow classifier model.
In this tutorial, we'll:
Utilize generator functions (
yield
) to progressively return content and update the app.Harness the power of reactive expressions (
pn.rx
) to facilitate dynamic updates to the app.
:::{note} When instructed to run the code, you can execute it directly in the Panel documentation using the green run button, in a notebook cell, or in a file named app.py
served with panel serve app.py --dev
. :::
Replace Content Progressively
Replace using a Generator
Let's kick off by replacing content progressively with the help of a generator function.
Click the Submit Button
to see it in action!
Exercise: Disable the Button
Now, let's enhance our app by disabling the button while the classification is running.
:::::{dropdown} Solution
:::::
Replace using Reactive Expressions
Another approach to achieve the same functionality is by using reactive expressions (pn.rx
).
Click the Submit Button
to observe the magic!
Append Content Progressively
Append using Generator
Now, let's explore how to append content progressively using a generator.
Exercise: Replace the Generator with Reactive Expressions
Let's reimplement the app using reactive expressions (pn.rx
), without using a generator function (yield
).
:::::{dropdown} Solution
:::::
Recap
In this tutorial, we've explored how to progressively update content in a Panel app:
We learned how to utilize generator functions (
yield
) for progressive updates.We also explored the usage of reactive expressions (
pn.rx
) for dynamic content updates.
Keep experimenting and building with Panel! 🚀
Resources
How to
Component Gallery
Feel free to reach out on Discord if you have any questions or need further assistance!