Python源码示例:panel.extension()

示例1
def __init__(self, data):
        super().__init__()
        xr.set_options(display_style='html')
        pn.extension(raw_css=[CSS])
        self.data = data
        self.panel = pn.pane.HTML(min_width=500, max_height=250, css_classes=['xrviz-scroll'])
        self.panel.object = "Description Section"
        self.setup() 
示例2
def do_import():
    error = too_old = False
    try:
        import panel as pn
        too_old = LooseVersion(pn.__version__) < LooseVersion("0.9.5")
    except ImportError as e:
        error = e

    if too_old or error:
        class GUI(object):
            def __repr__(self):
                raise RuntimeError("Please install panel to use the GUI `conda "
                                   "install -c conda-forge panel>=0.8.0`. Import "
                                   "failed with error: %s" % error)
        return GUI

    try:
        from .gui import GUI
        css = """
        .scrolling {
          overflow: scroll;
        }
        """
        pn.config.raw_css.append(css)  # add scrolling class from css (panel GH#383, GH#384)
        pn.extension()

    except Exception as e:

        class GUI(object):
            def __repr__(self):
                raise RuntimeError("Initialisation of GUI failed, even though "
                                   "panel is installed. Please update it "
                                   "to a more recent version (`conda install -c"
                                   " conda-forge panel>=0.9.5`).")
    return GUI