Shiny for Python 0.5.0

Style tweaks, table filtering, tooltips–and an appearance on the Talk Python podcast!
Author

Joe Cheng

Published

August 9, 2023

Shiny for Python 0.5.0

Another Shiny for Python release has arrived! In fact, we released 0.5.0 and then quickly followed it with 0.5.1, which fixes a sidebar bug we introduced in 0.5.0. Sorry about that!

You can upgrade to Shiny for Python 0.5.1 by running pip install -U shiny or conda install -c conda-forge shiny.

Style tweaks

We’ve tweaked the default Shiny CSS theme to make your apps look cleaner and more modern. In the screenshots below, you’ll notice differences in the slider and button, as well as shifts in the default typeface, font weights, and colors.

(The old theme is on the left, and the new theme is on the right.)

(old theme)

App with old sidebar App with old sidebar

(new theme)

We’ve found that tick marks are usually not that helpful on slider inputs, since you get instant feedback above the handle as you drag. If you want them back, you can pass ticks=True to input_slider().

These theme changes will be available to Shiny for R as well, via a new bslib CRAN release that should drop this week.

Data table filtering

In case you missed it, last month we introduced an interactive data table output that’s designed to easily scale to tens of thousands of rows. This month, we’ve added the ability to let viewers filter the data table by column.

Currently, the filter feature must be enabled by passing filters=True when creating your render.DataGrid or render.DataTable object:

  @output
  @render.data_frame
  def mygrid():
    return render.DataGrid(my_df, filters=True)

Tooltips

We’ve added a new tooltip feature, available in shiny.experimental namespace. They’re useful for providing additional information about an input or output, without taking up any extra space in your app.

from shiny import ui
import shiny.experimental as x

x.ui.tooltip(
    ui.input_slider("n", "N", 0, 100, 20),
    "A value to be doubled"
)

A mouse moving over a slider input, causing a tooltip to appear

Tooltips can be combined with help icons, which are available in the faicons package. You can add tooltip help icons in input labels by passing a list to the label argument of input_*() functions:

import shiny.experimental as x
from faicons import icon_svg

ui.input_text(
    "name",
    label=[
        "Name ",
        x.ui.tooltip(
            icon_svg("circle-info", fill_opacity=0.5),
            "Your full name"
        )
    ],
)

A mouse moving over a help icon in an input label, causing a tooltip to appear]

Talk Python podcast

I had a great time talking with Michael Kennedy on the Talk Python to Me podcast about Shiny for Python. We covered a lot of ground, including who Shiny is designed for, how Shiny differs from Jupyter notebooks, and how it compares to other Python web frameworks. Check it out!


That’s it for today! As always, if you have any questions or feedback, please join us on Discord or open an issue on GitHub. And if you’re enjoying Shiny for Python, please consider starring us on GitHub to show your support!