Skip to main content

Selectors

Selectors are interactive controls — dropdowns, date pickers, text inputs, and more — that you create in Python to make your notebooks and data apps interactive. Users pick one or more values from a set of options, and your code reacts to their choices, so the same notebook can be driven by anyone without editing code.

Getting started

MINEO provides several interactive controls for your notebooks. You can find their specific definitions on the following snippet pages. A selector must be defined and rendered in a specific block by creating a new instance of its class and calling its render method.

datepicker_1 = selectors.DatePicker('DatePicker1', label='A single date for A', default_value='07/09/2023')
datepicker_1.render()

Value access

After its definition, the value of a selector can be accessed in any block through the value property.

datepicker_1.value

Rendering

In addition to the render method, the selector can be rendered embedded into custom HTML code.

from IPython.display import display, HTML
datepicker_1 = selectors.DatePicker('DatePicker-1', label='A single date for A', default_value='07/09/2017')
display(HTML("""
<table border=1>
<tr>
<td>{0}</td><td>{1}</td>
</tr>
</table>
""".format(datepicker_1, datepicker_1.value)
))

Retrieving values from URL query parameters

MINEO automatically captures URL query parameters and makes them available through the MINEO_SELECTORS dictionary. This is particularly useful for pre-configuring notebooks with initial values when shared via links.

Accessing URL values

To retrieve values passed in the URL (e.g., ?text_selector=custom_value&date_picker=2023-12-31), use the MINEO_SELECTORS dictionary in your first code blocks:

# Access all URL parameters
print(MINEO_SELECTORS)

# Safely retrieve a specific selector value with fallback
text_value = MINEO_SELECTORS.get('text_selector', 'default_text')
date_value = MINEO_SELECTORS.get('date_picker', '2023-01-01')

print(f"Text value: {text_value}, Date value: {date_value}")

Selector common arguments

All selectors in the interactive selectors API have the following arguments that can be passed to their constructors:

ArgumentTypeDescription
selector_namestrInternal name of the selector. Must be unique in the notebook.
labelstrDisplay name of the selector.
help_textstrText that will appear as help when the pointer hovers over the selector.
run_on_changeboolIf True, the block is run after a user changes the value of the selector.
run_all_on_changeboolIf True, all blocks with higher sequence number are run after a user changes the value of the selector.
default_valuestrIf the value of the selector is invalid or not defined, selector.value will return this value.
ignore_user_inputboolIf True, the value of the selector will always be default_value.
allowed_valuesList[str]List of valid values for the selector.
stylestrPlain CSS rules that will be applied to the selector HTML element as inline rules, just as the web browser element.style tweaks.
block_uuidstrOptional value to indicate the block that will be executed when the selector change.
warning

The style argument lets you customize the selector's appearance with inline CSS rules. It is intended for advanced users and may produce unexpected results if the rules conflict with MINEO's own styling — use it sparingly.

See also

  • Selector types — the catalog of available selector controls and their specific options.
  • Widgets — interactive components for building data apps and dashboards.
  • Notebooks — where selectors live and run.