APIs#
Panel can be used to make a simple app in minutes, but you can also create complex apps with fully customized behavior and appearance. You can even flexibly integrate GUI support into long-term, large-scale software projects, while keeping your GUI code fully separate from the core code for your project.
To accommodate these different ways of using Panel, multiple APIs are available. Nearly all of the functionality of Panel can be accessed using any of the APIs, but each makes certain things much, much easier than others.
Letās work through each API with an example app, while pointing out the benefits and drawbacks along the way. Hereās a quick summary:
The
Reactive API
approach allows you to define a reactive function that is bound directly to a set of widgets usingpn.bind
. This API is efficient while still being explicit, flexible, and maintainable. We recommend this for most users and most projects, especially when you are first starting out.When writing libraries or other code that might be used independently of the actual GUI, a Parameterized class can be a great way to organize your core code while still supporting an optional GUI interface. In this case, dive into the
Declarative API
.If you need low-level control to implement fully arbitrary event handling, either alone or alongside any of the other approaches, defining explicit callbacks can be done with the
Callbacks API
.
Background on the use of Param in Panel.
A deep dive into the reactive and callback based APIs in Panel.
A discussion that contrasts function and class based APIs in Panel.
Next let us contrast the different APIs offered by Panel by applying them to a particular problem.
Linking functions or methods to widgets using pn.bind
or the equivalent pn.depends
decorator.
Declare Parameters and their ranges in Parameterized
classes, then get GUIs (and value checking!) for free.
Generate a UI by manually declaring callbacks that update panels or panes.
Examples#
Below are additional recipes using each API to create additional apps.
Build a stock explorer app using the .param.watch
callback API.
Build a stock explorer app using the Param based declarative API.
Build a stock explorer app using the reactive API.
Build a simple outlier explorer app using the declarative API.