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

Embedding editable sliders fails (EditableFloatSlider, EditableIntSlider) #6374

Closed
alcrene opened this issue Feb 22, 2024 · 0 comments · Fixed by #6391
Closed

Embedding editable sliders fails (EditableFloatSlider, EditableIntSlider) #6374

alcrene opened this issue Feb 22, 2024 · 0 comments · Fixed by #6391
Milestone

Comments

@alcrene
Copy link

alcrene commented Feb 22, 2024

ALL software version info

Panel: 1.3.8
Python: 3.10.12
OS: Linux

Description of expected behavior and the observed behavior

Calling .embed() on a layout containing either a EditableFloatSlider or EditableIntSlider raises an AttributeError.

In both cases, the code ends up in ContinuousSlider._get_embed_state, but this line

w_model, parent = self._models[ref]

does not actually assign the slider object into w_model (instead it assigns a Column, which contains both the slider, its label and spinner widget). Then a few lines later, this fails
start, end, step = w_model.start, w_model.end, w_model.step

because since w_model is a Column, it has no start attribute.

Complete, minimal, self-contained example code that reproduces the issue

import panel as pn
pn.extension()
layout = pn.Column(pn.widgets.EditableIntSlider())
layout.embed()

The error also occurs with EditableIntSlider.

It does not occur with EditableRangeSlider, IntSlider or FloatSlider.

Stack traceback and/or browser JavaScript console output

File ~/.cache/pypoetry/virtualenvs/ergm-sampling-nsRVGxGR-py3.10/lib/python3.10/site-packages/panel/viewable.py:942, in Viewable.embed(self, max_states, max_opts, json, json_prefix, save_path, load_path, progress, states)
    912 def embed(
    913     self, max_states: int = 1000, max_opts: int = 3, json: bool = False,
    914     json_prefix: str = '', save_path: str = './', load_path: Optional[str] = None,
    915     progress: bool = False, states={}
    916 ) -> None:
    917     """
    918     Renders a static version of a panel in a notebook by evaluating
    919     the set of states defined by the widgets in the model. Note
   (...)
    940       A dictionary specifying the widget values to embed for each widget
    941     """
--> 942     return render_embed(
    943         self, max_states, max_opts, json, json_prefix, save_path,
    944         load_path, progress, states
    945     )

File ~/.cache/pypoetry/virtualenvs/ergm-sampling-nsRVGxGR-py3.10/lib/python3.10/site-packages/panel/io/notebook.py:522, in render_embed(panel, max_states, max_opts, json, json_prefix, save_path, load_path, progress, states)
    520 with config.set(embed=True):
    521     model = panel.get_root(doc, comm)
--> 522     embed_state(panel, model, doc, max_states, max_opts,
    523                 json, json_prefix, save_path, load_path, progress,
    524                 states)
    525 return Mimebundle(render_model(model))

File ~/.cache/pypoetry/virtualenvs/ergm-sampling-nsRVGxGR-py3.10/lib/python3.10/site-packages/panel/io/embed.py:271, in embed_state(panel, model, doc, max_states, max_opts, json, json_prefix, save_path, load_path, progress, states)
    268     continue
    270 # Get data which will let us record the changes on widget events
--> 271 w, w_model, vals, getter, on_change, js_getter = widget._get_embed_state(
    272     model, states.get(widget), max_opts)
    273 w_type = w._widget_type
    274 if isinstance(w, DiscreteSlider):

File ~/.cache/pypoetry/virtualenvs/ergm-sampling-nsRVGxGR-py3.10/lib/python3.10/site-packages/panel/widgets/slider.py:126, in ContinuousSlider._get_embed_state(self, root, values, max_opts)
    123 _, _, doc, comm = state._views[ref]
    125 # Compute sampling
--> 126 start, end, step = w_model.start, w_model.end, w_model.step
    127 if values is None:
    128     span = end-start

File ~/.cache/pypoetry/virtualenvs/ergm-sampling-nsRVGxGR-py3.10/lib/python3.10/site-packages/bokeh/core/has_props.py:367, in HasProps.__getattr__(self, name)
    364 if isinstance(descriptor, property): # Python property
    365     return super().__getattribute__(name)
--> 367 self._raise_attribute_error_with_matches(name, properties)

File ~/.cache/pypoetry/virtualenvs/ergm-sampling-nsRVGxGR-py3.10/lib/python3.10/site-packages/bokeh/core/has_props.py:375, in HasProps._raise_attribute_error_with_matches(self, name, properties)
    372 if not matches:
    373     matches, text = sorted(properties), "possible"
--> 375 raise AttributeError(f"unexpected attribute {name!r} to {self.__class__.__name__}, {text} attributes are {nice_join(matches)}")

AttributeError: unexpected attribute 'start' to Column, possible attributes are align, aspect_ratio, auto_scroll_limit, children, context_menu, css_classes, disabled, flow_mode, height, height_policy, js_event_callbacks, js_property_callbacks, margin, max_height, max_width, min_height, min_width, name, resizable, scroll_button_threshold, scroll_position, sizing_mode, spacing, styles, stylesheets, subscribed_events, syncable, tags, view_latest, visible, width or width_policy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants