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

Bare component returned by pn.bind cannot be updated by other callbacks #6044

Closed
TheoMathurin opened this issue Dec 14, 2023 · 2 comments · Fixed by #6055
Closed

Bare component returned by pn.bind cannot be updated by other callbacks #6044

TheoMathurin opened this issue Dec 14, 2023 · 2 comments · Fixed by #6055
Milestone

Comments

@TheoMathurin
Copy link
Contributor

TheoMathurin commented Dec 14, 2023

Panel 1.3.4 in a server

If a pn.bind returns a widget or a pane on its own, meaning not embedded in a layout, this component cannot be updated by other callbacks. It's the case for every parameter I've tried: value, disabled, loading, visible, enabled_dates...

Put it in a container and it's fine.

Here is a simple example:

import panel.widgets as pnw
import panel as pn


def bare_widget(value):
    return int_input1


def widget_in_row(value):
    return pn.Row(int_input2)


def callback(event):
    int_input1.visible = not int_input1.visible
    int_input2.visible = not int_input2.visible


dummy_checkbox = pnw.Checkbox(name='Dummy checkbox', value=True)
int_input1 = pnw.IntInput(value=10)
int_input2 = pnw.IntInput(value=10)
button = pnw.Button(name='Update widget', on_click=callback)

pn.Column(button,
          'Bare widget:',
          pn.bind(bare_widget, dummy_checkbox),
          'Widget in a Row:',
          pn.bind(widget_in_row, dummy_checkbox)
          ).servable()

No error is logged either in Python or Javascript.

pnbind_bug

@philippjfr philippjfr added this to the v1.3.5 milestone Dec 14, 2023
@philippjfr
Copy link
Member

There's two conflated issues here, the first is that your example reuses int_input twice, which sadly is not possible currently. Presumably you just did that to create an MRE though, the other issue is quite frustrating and I'll push a fix shortly.

@TheoMathurin
Copy link
Contributor Author

Yes it was for the purpose of the MRE and I did not have this other limitation in mind. I will update it to use separate widget instances.

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