API Reference

Complete API documentation for EZInput classes and methods

Importing EZInput

# Recommended: Auto-detects environment
from ezinput import EZInput

# Alternative: Import specific implementation
from ezinput import EZInputJupyter  # For Jupyter notebooks
from ezinput import EZInputPrompt   # For terminal

💡 Auto-Detection

EZInput automatically detects whether you're in a Jupyter notebook or terminal and uses the appropriate implementation. In most cases, you should use from ezinput import EZInput.

EZInput Class

EZInput(title: str)

Main class for creating unified GUIs that work in both Jupyter and terminal.

Parameters

Example

gui = EZInput("image_analysis_v2")
# Config saved to: ~/.ezinput/image_analysis_v2.yml

⚠️ Important: Unique Titles

Each distinct GUI should have a unique title to avoid configuration conflicts:

  • ✅ Good: "preprocessing_v1", "cell_segmentation", "user_johndoe_analysis"
  • ❌ Bad: "test", "gui", "main"

Core Methods

show()

Display the GUI and collect user input.

gui.show()  # Display the GUI

get_values() → dict

Returns a dictionary of all widget objects indexed by their unique_tag.

values = gui.get_values()
threshold_value = values["threshold"].value
method_value = values["method"].value

__getitem__(unique_tag: str) → widget

Access a widget by its unique_tag using dictionary-style indexing.

threshold_widget = gui["threshold"]
print(threshold_widget.value)

# Update value
gui["threshold"].value = 0.8

Configuration Methods

save_parameters(filename: str)

Save current parameter values to a YAML file.

# Save to default location
gui.save_parameters("optimal_params.yml")
# Saved to: ~/.ezinput/optimal_params.yml

# Save to specific path
gui.save_parameters("/path/to/configs/experiment1.yml")

load_parameters(filename: str)

Load parameter values from a YAML file. Call before adding widgets to use loaded values as defaults.

gui = EZInput("analysis")
gui.load_parameters("optimal_params.yml")  # Load first

# Widgets will use loaded values as defaults
threshold = gui.add_float_range("thresh", "Threshold:", 0, 1)
gui.show()

remember_value(unique_tag: str)

Mark a widget's value to be remembered across sessions.

method = gui.add_dropdown("method", ["A", "B"], "Method:")
gui.remember_value("method")  # Remember this value

# Next run: method will default to previously selected value

Widget Methods Quick Reference

For detailed widget documentation, see the Widget Reference.

Method Widget Type Availability
add_text() Single-line text input Both
add_text_area() Multi-line text input Both
add_int_range() Integer slider/input with bounds Both
add_float_range() Float slider/input with bounds Both
add_int_text() Integer input (no bounds) Both
add_float_text() Float input (no bounds) Both
add_bounded_int_text() Integer with validation Both
add_bounded_float_text() Float with validation Both
add_check() Boolean checkbox/yes-no Both
add_dropdown() Selection from list Both
add_file_upload() Visual file picker Jupyter only
add_path_completer() Path autocomplete Terminal only
add_label() Static text/header Both
add_output() Output display area Jupyter only
add_HTML() Rich HTML content Jupyter only
add_callback() Action button/execution Both

Command Line Interface

ezinput <notebook.ipynb>

Execute a Jupyter notebook from the terminal. EZInput GUIs in the notebook will appear as terminal prompts.

# Run notebook from terminal
ezinput my_analysis.ipynb

# GUIs appear as interactive prompts
# Values are collected, then notebook executes

💡 Use Cases

  • Batch processing multiple datasets
  • Running notebooks on remote servers
  • Integrating notebooks into shell scripts
  • Automated workflows with parameter input

Advanced Topics

Value Priority Order

When multiple sources provide values for a widget:

  1. Loaded parameters (highest priority) - from load_parameters()
  2. Remembered values - from previous sessions using remember_value=True parameter
  3. Explicit defaults - passed to widget methods
  4. Widget defaults (lowest priority) - built-in fallbacks

Configuration File Location

Configuration files are stored in:

~/.ezinput/{title}.yml

You can also specify absolute paths for save_parameters() and load_parameters().

Widget Ordering

Widgets appear in the order they are added:

gui.add_label(value="=== Section 1 ===")  # First
gui.add_text("name", "Name:")               # Second
gui.add_int_range("age", "Age:", 0, 120)    # Third
gui.show()  # Displays in this order

Further Reading

📖 Widget Reference

Detailed documentation for all widgets

View Widgets →

⚙️ Configuration Guide

Deep dive into persistence and configs

Read Guide →