I want to display a pandas dataframe
in which at the begining of each row there is a Checkbox
(ipywidget
) to know which row the user is selecting.
I have made a frist trial with a Button
using the following code
import pandas as pd
from IPython.display import display, HTML
from ipywidgets import Button, HBox, VBox,widgets
import ipywidgets
from ipyleaflet import Map
mS2 = Map(center=(40.4, -3.7), zoom=6)
offlineS2 = ['true', 'false']
nameS2 = ['a','b']
df = pd.DataFrame({'Name': nameS2,'Offile': offlineS2})
# ideally I would need Checkbox not Button
button0 = widgets.Button(description='Click to display')
button1 = widgets.Button()
button2 = widgets.Button(description='Select')
dfW = ipywidgets.HTML(df.style.set_table_attributes('class="table"').render())
testup = HBox([VBox([button0,button1,button2]),dfW])
display(VBox([testup,mS2]))
However, when I change in the code widgets.Button
by widgets.Checkbox
, although it is displayed, the distance between the checkbox and the dataframe is too large. Why is this hapenning?
EDIT
Using
`button1 = widgets.Button(indent=False)`