Reputation: 71
Need to set an ipywidget container widget(HBox, VBox, ect.) inside a Tab The following is a dummy example of what I trying to do just using a list of Text widgets as a stand in for any other widget
Create a list of what will be in the VBox widget, bind this list of widgets to a VBox, then display that resulting VBox; and this works as expected:
import ipywidgets as widgets
from IPython.display import display
#just "dummy" widgets for exsample
subwids=[widgets.Text(value='Hello City'),
widgets.Text(value='Hello State'),
widgets.Text(value='Hello country '),
widgets.Text(value='Hello Contant'),
widgets.Text(value='Hello Continent')
]
#bind the dummy widgets to a VBox
BOX=widgets.VBox(subwids)
#display the VBox
display(BOX)
Now I am trying to set the existing VBox in a Tab in the Tab widget, and this is where it won't work and throws an error that can be seen when running the following:
tab=widgets.Tab(BOX)
tab.set_title(0, 'GeoLevels')
display(tab)
But what I would want it to do is except the VBox in the tab just like I would do in Qt
Upvotes: 1
Views: 4318
Reputation: 11
When I reproduced your example I ran into:
TraitError: The 'children' trait of a Tab instance must be a tuple, but a value of class 'ipywidgets.widgets.widget_box.VBox' was specified.
Following which, I passed it as a tuple:
tab=widgets.Tab((BOX,))
tab.set_title(0, 'GeoLevels')
display(tab)
Now it displays the tab.
Upvotes: 1