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

ReactiveHTML: ValueError: failed to validate #5451

Open
MarcSkovMadsen opened this issue Aug 27, 2023 · 1 comment
Open

ReactiveHTML: ValueError: failed to validate #5451

MarcSkovMadsen opened this issue Aug 27, 2023 · 1 comment
Labels
type: bug Something isn't correct or isn't working
Milestone

Comments

@MarcSkovMadsen
Copy link
Collaborator

I'm on the main branch of Panel using Bokeh 3.2.1. I'm working on improving the ReactiveHTML docs.

When I serve the below I get

import panel as pn
import param

pn.extension()

class CustomGauge(pn.reactive.ReactiveHTML):
  value = param.Integer(0, bounds=(0,100))

  _child_config = {"value": "literal"}
  
  _template=  """
<div id="container" class="pn-container">${value}</div>
"""

gauge = CustomGauge(value=55, styles={"border": "2px solid lightgray"}, height=400, sizing_mode="stretch_width")

pn.Column(gauge, gauge.param.value).servable()
ValueError: failed to validate value2(id='p1014', ...).value: expected a value of type str, got 55 of type int

image

I believe its a bug.

@MarcSkovMadsen MarcSkovMadsen added the type: bug Something isn't correct or isn't working label Aug 27, 2023
@MarcSkovMadsen MarcSkovMadsen added this to the next milestone Aug 27, 2023
@MarcSkovMadsen
Copy link
Collaborator Author

MarcSkovMadsen commented Aug 27, 2023

Trying to figure out what works and what does not work I played with the SlideShow example. Changing the index to a String parameter.

I want to use the value both in the src attribute and in a div.

import panel as pn
import param

from panel.reactive import ReactiveHTML

pn.extension()

class Slideshow(ReactiveHTML):

    index = param.String(default="0")

    _child_config = {"index": "literal"}

    _template = '<img id="slideshow" src="https://picsum.photos/800/300?image=${index}" onclick="${_img_click}"></img><div id="other">${index}</div>'

    def _img_click(self, event):
        self.index = str(int(self.index)+1)
        print(self.index)


Slideshow(width=500, height=200).servable()

When I click the image the div value updates but the image src does not.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't correct or isn't working
Projects
None yet
Development

No branches or pull requests

1 participant