This Towards Data Science blog has a lot of useful information. Also need to run jupyter nbextension enable --py widgetsnbextension.

In [1]:
import ipywidgets as widgets
from ipywidgets import interact, interact_manual

This is similar to the Groovy scripts of Active Choices parameters.

In [2]:
def states():
    return ['Sao Paulo', 'Minas Gerais', 'Acre']

def cities(state):
    if state == 'Sao Paulo':
        return ['Sao Paulo', 'Campinas', 'Barretos']
    elif state == 'Minas Gerais':
        return ['Betim', 'Belo Horizonte']
    elif state == 'Acre':
        return ['Acrelandia', 'Rio Branco']
        return ['UNKNOWN']

The states can be turned into a widget with interact.

In [3]:
selected_state = None
def show_states(state=states()):
    global selected_state
    print(f'You selected {state}')
    selected_state = state
In [4]:
def show_cities(city=cities(state=selected_state)):
    print(f'You selected {city}')

Or using the observe function.

In [5]:
# initial value
states_dropdown = widgets.Dropdown(options=states())
cities_dropdown = widgets.Dropdown(options=cities(state=states_dropdown.value))

# react to an event
def update_cities(state):
    if hasattr(state, 'new'):
        state =
    cities_dropdown.options = cities(state=state)

# create reactivity (same as reference parameter = cities in Jenkins/Active Choices)
states_dropdown.observe(update_cities, 'value')

# add a button (to call Jenkins?)
def submit_jenkins_job(event):
    selected_state = states_dropdown.value
    selected_city  = cities_dropdown.value
    print(f'Submitting a job with parameters state={selected_state}, city={selected_city}')

button = widgets.Button(
    description='Submit Job',
    tooltip='This will use Jenkins API with the auth settings...'

# render
display(states_dropdown, cities_dropdown, button)
Submitting a job with parameters state=Sao Paulo, city=Sao Paulo
Submitting a job with parameters state=Minas Gerais, city=Belo Horizonte

The function can use pandas, matplotlib, notebook widgets for images, etc. Pretty much anything available for Notebooks, or custom code/widgets too. More options and more extensible than with Jenkins.