示例#1
0
文件: idom.py 项目: brl0/panel
    def install(cls, packages, ignore_installed=False, fallback=None):
        """
        Installs specified packages into application directory.

        Arguments
        ---------
        packages: list or tuple
          The packages to install from npm
        ignored_installed: boolean
          Whether to ignore if the package was previously installed.
        fallback: str or idom.component
          The fallback to display while the component is loading
        """
        import idom
        from idom.config import IDOM_CLIENT_BUILD_DIR
        idom_dist_dir = DIST_DIR / "idom"
        idom_build_dir = idom_dist_dir / "build"
        if not idom_build_dir.is_dir():
            idom_build_dir.mkdir()
            shutil.copyfile(idom_dist_dir / 'package.json',
                            idom_build_dir / 'package.json')
        if IDOM_CLIENT_BUILD_DIR.get() != idom_build_dir:
            IDOM_CLIENT_BUILD_DIR.set(idom_build_dir)
            # just in case packages were already installed but the build hasn't been
            # copied over to DIST_DIR yet.
            ignore_installed = True
        return idom.install(packages, ignore_installed, fallback)
示例#2
0
def test_install_multiple():
    # install several random JS packages
    pad_left, decamelize, is_sorted = idom.install(
        ["pad-left", "decamelize", "is-sorted"])
    # ensure the output order is the same as the input order
    assert pad_left.url.endswith("pad-left.js")
    assert decamelize.url.endswith("decamelize.js")
    assert is_sorted.url.endswith("is-sorted.js")
示例#3
0
文件: idom.py 项目: rmorshea/panel
    def install(cls, packages, ignore_installed=False, fallback=None):
        """
        Installs specified packages into application directory.

        Arguments
        ---------
        packages: list or tuple
          The packages to install from npm
        ignored_installed: boolean
          Whether to ignore if the package was previously installed.
        fallback: str or idom.component
          The fallback to display while the component is loading
        """
        import idom
        import idom.client.manage
        idom.client.manage.APP_DIR = DIST_DIR / 'idom'
        idom.client.manage.BUILD_DIR = DIST_DIR / 'idom' / 'build'
        idom.client.manage.WEB_MODULES_DIR = DIST_DIR / 'idom' / 'build' / 'web_modules'
        return idom.install(packages, ignore_installed, fallback)
示例#4
0
def test_installed_module(driver, display):
    victory = idom.install("[email protected]")
    display(victory.VictoryBar)
    driver.find_element_by_class_name("VictoryContainer")
示例#5
0
def victory():
    return idom.install("[email protected]")
示例#6
0
import idom

material_ui = idom.install("@material-ui/core", fallback="loading...")

idom.run(
    idom.component(
        lambda: material_ui.Button(
            {"color": "primary", "variant": "contained"}, "Hello World!"
        )
    )
)
示例#7
0
import idom

victory = idom.install("victory", fallback="loading...")

idom.run(
    idom.component(
        lambda: victory.VictoryBar({"style": {
            "parent": {
                "width": "500px"
            }
        }}), ))
from pathlib import Path

import idom


# we use this to make writing our React code a bit easier
idom.install("htm")

path_to_source_file = Path(__file__).parent / "super_simple_chart.js"
ssc = idom.Module("super-simple-chart", source_file=path_to_source_file)


idom.run(
    idom.component(
        lambda: ssc.SuperSimpleChart(
            {
                "data": [
                    {"x": 1, "y": 2},
                    {"x": 2, "y": 4},
                    {"x": 3, "y": 7},
                    {"x": 4, "y": 3},
                    {"x": 5, "y": 5},
                    {"x": 6, "y": 9},
                    {"x": 7, "y": 6},
                ],
                "height": 300,
                "width": 500,
                "color": "royalblue",
                "lineWidth": 4,
                "axisColor": "silver",
            }
示例#9
0
def htm():
    return idom.install("[email protected]")