Develop in an Editor
Welcome to the "Develop in an Editor" section! Here, we'll explore how to develop Panel apps efficiently right within your favorite editor.
Let's dive in!
Serve Your App with Autoreload
Let's serve our app with autoreload. Autoreload ensures that your app updates in real-time as you make changes, providing a smooth development experience.
Serving Your App
Imagine you have a simple Panel app like the following:
Copy this code into a file named app.py
and save it.
Now, open a terminal and run the following command:
This will start the server and provide you with a URL where your app is being served. Open this URL in your browser to see your app in action.
It should look like
Now change the
ACCENT
value toteal
and save theapp.py
file.bins
value to15
and save.title
value to"My Matplotlib App"
and save.
It should look like
Inspect via Hover
One of the benefits of developing in an editor is the ability to inspect Panel objects conveniently via hover. Simply hover over the object you want to inspect, and you'll see tooltips providing useful information and links to reference guides.
Let's say you want to inspect the FastListTemplate
object in your code. Hover over it, and you'll see a tooltip with an example code snippet and a reference link. Clicking the reference link takes you directly to the reference guide for further information.
Inspect via print
Another handy way to inspect objects is by printing them. This allows you to see detailed information about the object's structure and contents.
Consider the following code snippet:
Serving this code will print information about the layout
object, revealing its structure and attributes.
Serve the app by running the below command in a terminal.
Open http://localhost:5006/app in a browser.
This will look something like the below in the terminal.
Inspect Parameters via .param
You can inspect the parameters of Panel components using the .param
namespace and its _repr_html_
method.
Copy the code below into a file app.py
:
Serve the app with panel serve app.py --dev
.
Open http://localhost:5006 in a browser.
It should look like
Recap
In this section, we've covered:
Serving your app with autoreload for seamless development.
Inspecting Panel objects conveniently via hover and
print
.Exploring component parameters using
.param
.
With these techniques, you can streamline your development workflow and build awesome Panel apps more efficiently!
Resources
For more advanced techniques and configuration options, check out the resources below:
Tutorials
How-to
Happy coding! 🚀