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

IPysheet comms not working if added dynamically #2633

Closed
MarcSkovMadsen opened this issue Aug 13, 2021 · 3 comments
Closed

IPysheet comms not working if added dynamically #2633

MarcSkovMadsen opened this issue Aug 13, 2021 · 3 comments
Labels
type: feature A major new feature

Comments

@MarcSkovMadsen
Copy link
Collaborator

MarcSkovMadsen commented Aug 13, 2021

Panel: 0.12.1
Ipywidgets: 7.6.3
IPysheet: 0.4.4
IPykernel: 5.5.5
jupyter-bokeh: 3.0.2
ipywidgets-bokeh: 1.0.2

For my "Introduction to Panel" I dynamically add/ remove "components" via a RadioButtonGroup. One example I have is for IPywidgets. And I notice the example with IPysheets does not work if it is not the "first" component I show. I.e. added when the app is loaded.

If I serve the code below and drag the slider I would expect the value in the ipysheet to update. But it does not.

ipysheet_not_updating.mp4
import ipysheet
import ipywidgets as ipw
import panel as pn

pn.extension("ipywidgets", sizing_mode="stretch_width")

def ipywidgets_example():
    return ipw.DatePicker(description='Date')

def ipysheet_example():
    slider = pn.widgets.FloatSlider(value=10, start=0, end=100)
    sheet = ipysheet.sheet()
    cell = ipysheet.cell(2,2, 10., read_only=True, background_color="whitesmoke")

    @pn.depends(slider, watch=True)
    def calculate(a):
        cell.value = a
        print("update", cell.value)

    return pn.Column(slider, sheet)

components = {
    "IPYWIDGETS": ipywidgets_example(),
    "IPYSHEET": ipysheet_example(),
}

def show(component):
    component = components[component]
    return component

select = pn.widgets.RadioButtonGroup(options=list(components.keys()))
show = pn.bind(show, component=select)

pn.template.FastListTemplate(
    main=[pn.Column(select,show)],
).servable()
@MarcSkovMadsen MarcSkovMadsen added the TRIAGE Default label for untriaged issues label Aug 13, 2021
@MarcSkovMadsen
Copy link
Collaborator Author

If I change the order of the components to

components = {
    "IPYSHEET": ipysheet_example(),
    "IPYWIDGETS": ipywidgets_example(),
}

it works initially. But if I navigate to the second component and back it no longer works.

does-not-work.mp4
import ipysheet
import ipywidgets as ipw
import panel as pn

pn.extension("ipywidgets", sizing_mode="stretch_width")

def ipywidgets_example():
    return ipw.DatePicker(description='Date')

def ipysheet_example():
    slider = pn.widgets.FloatSlider(value=10, start=0, end=100)
    sheet = ipysheet.sheet()
    cell = ipysheet.cell(2,2, 10., read_only=True, background_color="whitesmoke")

    @pn.depends(slider, watch=True)
    def calculate(a):
        cell.value = a
        print("update", cell.value)

    return pn.Column(slider, sheet)

components = {
    "IPYSHEET": ipysheet_example(),
    "IPYWIDGETS": ipywidgets_example(),
}

def show(component):
    component = components[component]
    return component

select = pn.widgets.RadioButtonGroup(options=list(components.keys()))
show = pn.bind(show, component=select)

pn.template.FastListTemplate(
    main=[pn.Column(select,show)],
).servable()

@MarcSkovMadsen
Copy link
Collaborator Author

I can see that when I navigate to the second component (no matter the order of components) there is a Wrong widget protocol version: received protocol version '', but was expecting major version '2'.

image

I don't know if this is the cause or a second error.

@MarcSkovMadsen MarcSkovMadsen added type: feature A major new feature and removed TRIAGE Default label for untriaged issues labels Aug 16, 2021
@philippjfr
Copy link
Member

ipysheet still has not published a bundle to npm after about a year of prodding so I'll consider it unmaintained and close this issue. There's also the ipywidgets_bokeh issue which is probably the cause of this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature A major new feature
Projects
None yet
Development

No branches or pull requests

2 participants