In [1]:
from ipywidgets import widgets

In [12]:
from IPython.display import display
text = widgets.Text()
display(text)

button = widgets.Button(description='Click me')
display(button)

def handle_text(sender):
    print(text.value)
    
def handle_button(b):
    print('clicked')

text.on_submit(handle_text)
button.on_click(handle_button)


aaa
clicked
clicked
aaa bbb

In [14]:
button = widgets.Button(
    description='Hello World!',
    width=30, # Integers are interpreted as pixel measurements.
    height='2em', # em is valid HTML unit of measurement.
    color='lime', # Colors can be set by name,
    background_color='#0022FF', # and also by color code.
    border_color='red')
display(button)

In [15]:
name = widgets.Text(description='Name:')
color = widgets.Dropdown(description='Color:', values=['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'])
page1 = widgets.Box(children=[name, color])

age = widgets.IntSlider(description='Age:', min=0, max=120, value=50)
gender = widgets.RadioButtons(description='Gender:', values=['male', 'female'])
page2 = widgets.Box(children=[age, gender])

tabs = widgets.Tab(children=[page1, page2])
display(tabs)

tabs.set_title(0, 'Name')
tabs.set_title(1, 'Details')