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:

  1. The Reactive API approach allows you to define a reactive function that is bound directly to a set of widgets using pn.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.

  2. 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.

  3. 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.

Parameters in Panel

Background on the use of Param in Panel.

Reactivity in Panel

A deep dive into the reactive and callback based APIs in Panel.

Functions vs Classes

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.

1. Reactive API

Linking functions or methods to widgets using pn.bind or the equivalent pn.depends decorator.

2. Declarative API

Declare Parameters and their ranges in Parameterized classes, then get GUIs (and value checking!) for free.

3. Callbacks API

Generate a UI by manually declaring callbacks that update panels or panes.


Below are additional recipes using each API to create additional apps.

Stock Explorer - Callback API

Build a stock explorer app using the .param.watch callback API.

Stock Explorer - Declarative API

Build a stock explorer app using the Param based declarative API.

Stock Explorer - Reactive API

Build a stock explorer app using the reactive API.

Outlier Explorer - Declarative API

Build a simple outlier explorer app using the declarative API.