Hi I have a simple that displays a  pandas dataframe. I update the 
dataframe in a callback to my button 'on_click' function.
The declarative widget does not pick-up the change. I have to explicitly 
evaluate the dataframe in a cell for the declarative widget to pick up the 
change.
import declarativewidgets as declwidgets
from ipywidgets import widgets # Widget definitions
from IPython.display import display # Used to display widgets in the 
notebook
declwidgets.init()

import pandas as pd
df1 = pd.DataFrame([
        [1, 3],
        [2, 4]     
    ], columns=["a", "b"]
)
def update_pd_df(df, data={}):
    cur_b = df.loc[df.a == data.get('a', None) ,'b']
    df.loc[df.a == data.get('a', None) ,'b'] = data.get('b', cur_b)


%%html

<link rel="stylesheet" type="text/css" href="bcard.css">
<link rel="import" 
href="urth_components/urth-viz-table/urth-viz-table.html" 
is="urth-core-import">
<template is="dom-bind">
    <urth-core-dataframe id="f1" ref="df1" value="{{df}}" auto 
></urth-core-dataframe>    
    <urth-viz-table datarows="{{ df.data }}" selection="{{sel}}" 
columns="{{ df.columns }}" rows-visible=6>
    </urth-viz-table>
</template>
btn = widgets.Button(description='click me')
def on_btn_clicked(b):
    update_pd_df(df1, data={'a': 1, 'b': 18})
    print('changing df1')
          
btn.on_click(on_btn_clicked)

display(btn)
df1 #now it updates


-- 
You received this message because you are subscribed to the Google Groups 
"Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jupyter/df37a9eb-85b9-46d8-a812-8db931afa9ee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to