예제 #1
0
def test_int_slider():
    # When/ Then
    slider = wired.IntSlider(attributes_to_watch={"value": "value"})
    slider.html = (
        '<wired-slider id="slider" value="2" knobradius="15" class="wired-rendered" '
        'style="margin: 0px"></wired-slider>')
    assert slider.value == 2
예제 #2
0
def test_int_slider_properties_last_change():
    slider = wired.IntSlider()

    # When/ Then
    slider.properties_last_change = {"input.value": "13"}
    assert slider.value == 13
예제 #3
0
def test_wired_view():  # pylint: disable=too-many-locals
    """Returns a column with all the wired elements"""
    show_html = False

    def section(component, message=None, show_html=show_html):
        title = "## " + str(type(component)).split(".")[4][:-2]

        parameterset = set(component._child_parameters())  # pylint: disable=protected-access
        if show_html:
            parameterset.add("html")
        for parameter in component.parameters_to_watch:
            parameterset.add(parameter)

        parameters = list(parameterset)
        if message:
            return (
                pn.pane.Markdown(title),
                pn.pane.Markdown(message),
                component,
                pn.Param(component, parameters=parameters),
                pn.layout.Divider(),
            )
        return (
            pn.pane.Markdown(title),
            component,
            pn.Param(component, parameters=parameters),
            pn.layout.Divider(),
        )

    button = wired.Button()
    check_box = wired.Checkbox()
    date_picker = wired.DatePicker()
    # dialog = wired.Dialog(text="Lorum Ipsum. Panel is awesome!")
    divider = wired.Divider()
    fab = wired.Fab()
    float_slider = wired.FloatSlider()
    icon_button = wired.IconButton()
    int_slider = wired.IntSlider()
    image = wired.Image(
        object="https://www.gstatic.com/webp/gallery/1.sm.jpg", height=200, width=300
    )
    link = wired.Link(href="https://panel.holoviz.org/", text="HoloViz", target="_blank")
    # literal_input = wired.LiteralInput(default={"a": 1, "b": "hello app world"})
    progress = wired.Progress(value=50)
    progress_spinner = wired.ProgressSpinner()
    radio_button = wired.RadioButton()
    search_input = wired.SearchInput()
    select = wired.Select(
        html="""<wired-combo id="colorCombo" selected="red" role="combobox" \
aria-haspopup="listbox" tabindex="0" class="wired-rendered" aria-expanded="false">\
<wired-item value="red" aria-selected="true" role="option" class="wired-rendered">Red</wired-item>\
<wired-item value="green" role="option" class="wired-rendered">Green</wired-item>\
<wired-item value="blue" role="option" class="wired-rendered">Blue</wired-item></wired-combo>"""
    )
    text_area = wired.TextAreaInput()
    text_input = wired.TextInput()
    toggle = wired.Toggle()
    video = wired.Video(
        autoplay=True,
        loop=True,
        object=(
            "https://file-examples.com/wp-content/uploads/2017/04/file_example_MP4_480_1_5MG.mp4"
        ),
    )
    section(select)
    return pn.Column(
        *section(button),
        *section(check_box),
        *section(date_picker),
        # *section(dialog),
        *section(divider),
        *section(fab),
        *section(float_slider, message="**Not fully implemented!**"),
        *section(icon_button),
        *section(image),
        *section(int_slider, message="**Not fully implemented!**"),
        *section(
            link,
            """Normally you would just use the `<wired-link>` tag directly in your html \
or markdown text""",
        ),
        # *section(literal_input),
        *section(progress),
        *section(radio_button),
        *section(search_input, message="**Not fully implemented!**"),
        *section(select, message="**Not fully implemented!**"),
        *section(progress_spinner),
        *section(text_area, message="**Not fully implemented!**"),
        *section(text_input, message="**Not fully implemented!**"),
        *section(toggle),
        *section(video),
        name="Elements",
    )