Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved panes and widgets into subpackage #283

Merged
merged 2 commits into from
Mar 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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