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

observe triggers twice when setting value with a tuple #66

Open
krey opened this issue Mar 6, 2019 · 0 comments
Open

observe triggers twice when setting value with a tuple #66

krey opened this issue Mar 6, 2019 · 0 comments

Comments

@krey
Copy link

krey commented Mar 6, 2019

import ipywidgets as widgets
import ipysheet

output = widgets.Output()
table = ipysheet.Sheet(rows=1, columns=2)
cell = ipysheet.Cell(value=("", ""), row_start=0, row_end=0, column_start=0, column_end=1,
                     squeeze_column=False, squeeze_row=True)
table.cells = cell,

def observer(change):
    with output:
        print(change)

cell.observe(lambda change: observer(change.new), names='value')

cell.value = ('a', 'b')

output

prints

('a', 'b')
['a', 'b']

This is probably a side-effect of serialization.

A simple workaround is to use lists, but this is somewhat inconsistent: Sheet.cells is a Tuple so I figured Cell.value would be as well.

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

No branches or pull requests

1 participant