[IPython-dev] Format of RadioButtonsWidget description and options

Doug Blank doug.blank at gmail.com
Thu Jul 3 13:59:45 EDT 2014


Devs,

We are working on creating a MultipleChoiceWidget, and wondering if there
are options for positioning, or using HTML in, say, the description.

For example, if you run the following in a Notebook:

```python

from IPython.html.widgets import (RadioButtonsWidget, ContainerWidget,
ButtonWidget)
from IPython.display import (display, clear_output)
answers = ["a) apple", "b) banana", "c) cherry"]
choices = RadioButtonsWidget(description="Q1: What is the best fruit?",
                                    values=answers)
button = ButtonWidget(description="Check Me")
container = ContainerWidget(children =[choices, button])

def on_click(button):
    clear_output()
    if answers.index(choices.value_name) == 1:
        print("Correct!! The best fruit is the banana")
    else:
        print("Incorrect. Try running the above code to see the best
fruit.")

button.on_click(on_click)
container
```
(see attached for image of output)

The description ("Q1: What is the best fruit?") appears to the left of the
radio buttons. Is there a way to get it to display above the radio buttons?
Is there a way to force a newline after the question?

Also, is there a way to use markup in the radio options?

Perhaps there is a need for a LabelWidget (as opposed to TextWidget for
entry) to do the question?

Any suggestions welcomed to make this work/act better.

-Doug
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20140703/591c0201/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screenshot from 2014-07-03 13:46:44.png
Type: image/png
Size: 52599 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20140703/591c0201/attachment.png>


More information about the IPython-dev mailing list