import ipywidgets
import IPython.display
import iris

"""
Explanation: Radio Button Menu
Example showing how to construct a radio button widget that can be used to select a cube dimension.
End of explanation
"""


cube = iris.load_cube(iris.sample_data_path('A1B.2098.pp'))
print cube

"""
Explanation: Load cube.
End of explanation
"""


coordinates = [(coord.name()) for coord in cube.coords()]

dim_x = ipywidgets.RadioButtons(
    description='Dimension:',
    options=coordinates,
    value='time')

IPython.display.display(dim_x)

"""
Explanation: Compose list of options and then construct widget to present them, along with a default option. Display the widget using the IPython display call.
End of explanation
"""


print dim_x.value

"""
Explanation: Print selected widget value for clarity.
End of explanation
"""


