Jupyter declarativewidgets change style

In my jupyter notebook, I want to have an interactive table, when the user selects a row, I show the corresponding values ​​in another table or graph.

I'm currently trying to use declarativewidgets (although if a simpler alternative were presented I'd be just as happy)

I had no problem setting up an example that worked perfectly and it was trivial to bind an event from one element to another, but I was unable to change the style of the elements. In particular, I want to be able to control the background color (and even make it alternate row wise) in a table across tables. I mean I will have multiple tables (the first is related to the next, related to the next, etc.) and I want each table to have a different background color.

What I have so far:

from IPython.display import display, Image
from IPython.core.display import HTML
from ipywidgets import *
import declarativewidgets
import pandas as pd
declarativewidgets.init()

      

Then I import the urth-viz table:

%%html
<link rel="import" href="urth_components/urth-viz-table/urth-viz-table.html" 
    is='urth-core-import'>

      

Then I have a function

def create_df():
    return pd.DataFrame({'one' : pd.Series([1., 2., 3.], index=['a', 'b', 'c']),
           'two' : pd.Series([1., 2., 3., 4.], index=['a', 'b', 'c', 'd'])})

      

And the following cell creates the first table:

%%html
<template is="urth-core-bind">
    <urth-core-function ref="create_df"
                    result="{{create_df}}" 
                    limit="1600"
                    delay="100" 
                    auto>
    </urth-core-function>
    <urth-viz-table datarows="{{ create_df.data }}" 
                rows-visible="19" 
                selection="{{first_selection}}" 
                columns="{{ create_df.columns }}" 
                selection-as-object>
    </urth-viz-table>
</template>

      

This works great and I can create new tables and graphs and link them to the behavior of the previous table. What I was not able to do is change any table style, will be especially appreciated for a specific example.

I am using python 3.6 jupyter 4.2.1 jupyter-dashboards 0.6.1 jupyter-declarativewidgets 0.7.0

+3


source to share





All Articles