jakevdp / ipywidgets-static

[obsolete] Static Widgets for IPython Notebooks
BSD 3-Clause "New" or "Revised" License
108 stars 24 forks source link

I added DropDown widgets. #5

Closed mglerner closed 10 years ago

mglerner commented 10 years ago

I had two issues when writing this:

1) As far as I know (I'm a JavaScript novice these days), there's no nice way to automatically loop over radio buttons, sliders and dropdowns. So, I used a function from http://stackoverflow.com/questions/914783/javascript-nodelist/17262552#17262552 to join two NodeLists.

2) If you have more than one widget, your output name is . But you build up your widget lists in two places (once in Python in StaticInteract._output_html, and once in JavaScript in interactUpdate). I ran into trouble where they would iterate through the widgets in different orders. I have a feeling I'm just doing something dumb, but I didn't see where. My workaround was to explicitly sort the list of widgets in alphabetical order. While I was at it, I made it show the widgets in alphabetical order as well. I don't know of any way to get them in the order they were declared, but I thought some defined order made the output easier to control.

I also updated the example IPython Notebook. In case it's troublesome: I'm using IPython 2.0, so the version updated.

jakevdp commented 10 years ago

Looks great! I'll take a closer look and test it out tomorrow

mglerner commented 10 years ago

Awesome! I just noticed that formatting ate part of my above comment (I used angle braces instead of square braces). 2) should read "If you have more than one widget, your output name is [Widget1Name][Widget1Value][Widget2Name][Widget2Value]..."

mglerner commented 10 years ago

It now displays the names in bold in front of the widget. I thought about fancier formatting, but I didn't want to conflict with custom formatting from users.

jakevdp commented 10 years ago

Just played with this a bit. It looks really nice! I'm going to merge it.