mwcraig / reducer

Friendly professional-level data reduction...documentation here:
https://reducer.readthedocs.org
BSD 3-Clause "New" or "Revised" License
26 stars 10 forks source link

Change accordion title setting for ipywidgets 7 #156

Closed mwcraig closed 7 years ago

mwcraig commented 7 years ago

The description attribute has been dropped but one can set_title.

The traceback is, in part:

~/Development/astronomy/reducer-notebook/reducer/image_browser.py in _create_gui(self)
    155                 old_parent = parent
    156                 grandparent = old_parent.parent
--> 157                 desc = old_parent.description
    158                 s_or_not = ['', 's']
    159                 n_files = len(index)

AttributeError: 'Accordion' object has no attribute 'description'

See this for an example of how to make this work:

a = ipw.Accordion()
b = ipw.Accordion()
c = ipw.Accordion()
b_1 = ipw.Accordion()
b_2 = ipw.Accordion()

c_kids = [ipw.Label(value="c-sub {}".format(i), description="Moo {}".format(i)) for i in range(10)]
c.children = c_kids

_ = [c.set_title(i, kid.value) for i, kid in enumerate(c.children)]

b.children = [b_1, b_2]
b.set_title(0, "b_1")
b.set_title(1, "b_2")

a.children = [b, c]
a.set_title(0, "b")
a.set_title(1, "c")
mwcraig commented 7 years ago

Well, that was easier to fix than I expected. Just did a simple monkey-patch adding a description to each accordion and box, and done!