@@ -48,13 +48,7 @@ def organized_widgets(organize_by='ui'):
48
48
'Valid options are: {valid_organizations}' )
49
49
50
50
all_wids = inspect .getmembers (widgets )
51
- # for a in all_wids:
52
- # name = a[0]
53
- # arf = a[1]
54
- # if (not name.startswith('_') and
55
- # name[0] in string.ascii_uppercase and
56
- # issubclass(arf, widgets.DOMWidget)):
57
- # print('woot')
51
+
58
52
widget_dict = {name : wid for name , wid in all_wids
59
53
if not name .startswith ('_' ) and
60
54
name [0 ] in string .ascii_uppercase and
@@ -131,8 +125,15 @@ def fill_container(widget, name):
131
125
132
126
# Set tab or accordion names
133
127
if name == "accordion" or name == "tab" :
134
- for i in range (len (widget .children )):
135
- widget .set_title (i , '{} {}' .format (name , i ))
128
+ titles = [f'{ name } { idx } ' for idx , _ in enumerate (widget .children )]
129
+ try :
130
+ # Retrieve the titles attribute to see if it exists
131
+ widget .titles
132
+ except AttributeError :
133
+ for idx , title in enumerate (titles ):
134
+ widget .set_title (idx , title )
135
+ else :
136
+ widget .titles = titles
136
137
137
138
# Start with all the accordions closed
138
139
if name == "accordion" :
@@ -219,7 +220,6 @@ def box_maker(name, widget, group):
219
220
return b
220
221
221
222
for group , group_widgets in groups .items ():
222
- # print(group)
223
223
titles .append (group )
224
224
col_spec = f"repeat({ columns } , minmax({ min_width_single_widget } px, 1fr)"
225
225
layout = widgets .Layout (grid_template_columns = col_spec ,
@@ -230,8 +230,16 @@ def box_maker(name, widget, group):
230
230
231
231
tabs .children = kids
232
232
233
- for i , title in enumerate (titles ):
234
- nice = title .replace ('_' , ' ' )
235
- tabs .set_title (i , nice .title ())
233
+ try :
234
+ # Try to access the titles attribute to see if it exists
235
+ tabs .titles
236
+ except AttributeError :
237
+ # We must be using ipywidgets 7, so set_titles
238
+ for i , title in enumerate (titles ):
239
+ nice = title .replace ('_' , ' ' )
240
+ tabs .set_title (i , nice .title ())
241
+ else :
242
+ # We have ipywidgets 8
243
+ tabs .titles = titles
236
244
237
245
return tabs
0 commit comments