Skip to content

Commit

Permalink
Moved panes into subpackage
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Mar 6, 2019
1 parent 3316fca commit b1f921f
Show file tree
Hide file tree
Showing 24 changed files with 863 additions and 772 deletions.
2 changes: 0 additions & 2 deletions examples/user_guide/Panes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
"outputs": [],
"source": [
"import panel as pn\n",
"import panel.vega\n",
"import panel.plotly\n",
"\n",
"pn.extension()"
]
Expand Down
6 changes: 2 additions & 4 deletions panel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
import param as _param
from bokeh.document import Document as _Document

from . import holoviews # noqa
from . import layout # noqa
from . import links # noqa
from . import pane # noqa
from . import param # noqa
from . import pipeline # noqa
from . import plotly # noqa
from . import vega # noqa
from . import widgets # noqa
from . import links # noqa

from .interact import interact # noqa
from .layout import Row, Column, Tabs, Spacer # noqa
Expand Down
9 changes: 5 additions & 4 deletions panel/interact.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
from __future__ import absolute_import, division, unicode_literals

import types
from numbers import Real, Integral
from collections import OrderedDict

from collections import OrderedDict
from inspect import getcallargs
from numbers import Real, Integral
from six import string_types

try: # Python >= 3.3
from inspect import signature, Parameter
Expand All @@ -37,7 +38,7 @@

from .layout import Panel, Column, Row
from .pane import PaneBase, Pane, HTML
from .util import basestring, as_unicode
from .util import as_unicode
from .widgets import (Checkbox, TextInput, Widget, IntSlider, FloatSlider,
Select, DiscreteSlider, Button)

Expand Down Expand Up @@ -280,7 +281,7 @@ def widget_from_abbrev(cls, abbrev, name, default=empty):
@staticmethod
def widget_from_single_value(o, name):
"""Make widgets from single values, which can be used as parameter defaults."""
if isinstance(o, basestring):
if isinstance(o, string_types):
return TextInput(value=as_unicode(o), name=name)
elif isinstance(o, bool):
return Checkbox(value=o, name=name)
Expand Down
2 changes: 1 addition & 1 deletion panel/links.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import sys

from .layout import Viewable, Panel
from .holoviews import HoloViews, generate_panel_bokeh_map, is_bokeh_element_plot
from .pane.holoviews import HoloViews, generate_panel_bokeh_map, is_bokeh_element_plot
from .util import unicode_repr

from bokeh.models import (CustomJS, Model as BkModel)
Expand Down
9 changes: 9 additions & 0 deletions panel/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""
The models module defines custom bokeh models which extend upon the
functionality that is provided in bokeh by default. The models are
defined as pairs of Python classes and TypeScript models defined in .ts
files.
"""

from .plots import PlotlyPlot, VegaPlot # noqa
from .widgets import Audio, FileInput, Player # noqa
39 changes: 39 additions & 0 deletions panel/models/plots.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""
Defines custom bokeh models to render external Javascript based plots.
"""
import os

from bokeh.core.properties import Dict, String, List, Any, Instance
from bokeh.models import LayoutDOM, ColumnDataSource

from ..util import CUSTOM_MODELS


class PlotlyPlot(LayoutDOM):
"""
A bokeh model that wraps around a plotly plot and renders it inside
a bokeh plot.
"""

__implementation__ = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'plotly.ts')

data = Dict(String, Any)

data_sources = List(Instance(ColumnDataSource))


class VegaPlot(LayoutDOM):
"""
A Bokeh model that wraps around a Vega plot and renders it inside
a Bokeh plot.
"""

__implementation__ = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'vega.ts')

data = Dict(String, Any)

data_sources = Dict(String, Instance(ColumnDataSource))


CUSTOM_MODELS['panel.plotly.PlotlyPlot'] = PlotlyPlot
CUSTOM_MODELS['panel.vega.VegaPlot'] = VegaPlot
Loading

0 comments on commit b1f921f

Please sign in to comment.