Search code examples
pythontabsbokehpanel

Did the Panel class move to another library in bokeh for new version of Bokeh


I have a bokeh application using Tabs and Panel widgets. I used to do: from bokeh.models import Tabs,Panel

I recently did a new installation of python 3.8 and subsequently bokeh (3.0.2) and now Panel cannot be imported from bokeh.models. Online examples cite importing from bokeh.models.widgets but that does not work either. The error message I get is cannot import name 'Panel' from 'bokeh.models.widgets' (C:\Users\_my_username_\AppData\Roaming\Python\Python38\site-packages\bokeh\models\widgets\__init__.py)


Solution

  • It looks like Panel has been renamed TabPanel in Bokeh 3.0.3.

    The docs for version 2.4.3 say this:

    Panel

    class Panel(*args, **kwargs)

    Bases: Model

    A single-widget container with title bar and controls.

    And the docs for version 3.0.3 say this:

    class TabPanel(*args: Any, id: ID | None = None, **kwargs: Any)

    Bases: Model

    A single-widget container with title bar and controls.

    Based on that information, I think they're referring to the same thing and from bokeh.models import TabPanel would work.