EZInput

Write once, run anywhere. The same GUI code for Jupyter notebooks and terminal applications.

Why EZInput?

🔄

Environment Auto-Detection

Automatically detects whether you're in Jupyter or terminal and displays the appropriate interface. No code changes needed.

💾

Value Persistence

Remembers your input values between sessions. Perfect for iterative workflows and parameter tuning.

📝

Shareable Configs

Save and load parameter sets as YAML files. Share configurations with your team or across projects.

🖥️

Notebook to CLI

Run Jupyter notebooks from the terminal with the ezinput command. Perfect for batch processing.

🎨

Rich Widget Library

Text input, sliders, dropdowns, file pickers, checkboxes, and more. All with consistent API across environments.

🔌

Simple Integration

Replace input() calls with EZInput widgets. Minimal code changes for maximum functionality gain.

Quick Start

Installation

pip install ezinput

For development version:

pip install git+https://github.com/HenriquesLab/EZInput.git

Your First GUI in 5 Lines

from ezinput import EZInput

gui = EZInput("my_first_app")
name = gui.add_text("name", "What's your name?")
age = gui.add_int_range("age", "Age:", 0, 120)
gui.show()

print(f"Hello {name.value}, you are {age.value} years old!")

This exact code works in both Jupyter notebooks and terminal! 🎉

📓 Jupyter Note: In notebooks, put the code that accesses .value (like the print statements) in a separate cell below gui.show(). Run it after you've entered your values!

Real-World Example: Image Analysis

from ezinput import EZInput
from pathlib import Path

# Create GUI with a memorable title (configs saved under this name)
gui = EZInput("image_segmentation_v3")

# File selection (text input with path)
input_file = gui.add_text("input_tif", "Input file path:", placeholder="/path/to/image.tif")

# Processing parameters with bounds
threshold = gui.add_float_range("threshold", "Threshold:", 0.0, 1.0)
min_size = gui.add_bounded_int_text("min_size", "Min object size:", 10, 1000)

# Optional settings
gpu_accel = gui.add_check("use_gpu", "Use GPU acceleration?")
method = gui.add_dropdown("method", ["watershed", "otsu", "adaptive"], 
                          "Segmentation method:")

# Display the GUI
gui.show()

# Access values
print(f"Processing {input_file.value}")
print(f"Threshold: {threshold.value}, Method: {method.value}")

📓 Jupyter Note: In notebooks, create a new cell after gui.show() for the code that accesses widget values. This allows you to interact with the widgets before accessing their values.

🖥️ Run Notebooks from Terminal

Execute your Jupyter notebooks as command-line tools with ezinput:

# Run a notebook from terminal
ezinput my_analysis.ipynb

# Works with EZInput GUIs inside the notebook!
# Prompts appear in terminal, configs are loaded automatically

Perfect for batch processing, automation, and integrating notebooks into pipelines.

🔥 Copy-Paste Anywhere

The same code works identically in:

  • Jupyter Notebook (.ipynb)
  • JupyterLab
  • Terminal Python scripts (.py)
  • IPython shell

No modifications needed! EZInput automatically detects the environment and adapts.

Widget Gallery

All the widgets you need, with consistent API across environments

📝 Text & Numbers

  • add_text() - Single line text
  • add_text_area() - Multi-line text
  • add_int_range() - Integer slider
  • add_float_range() - Float slider
  • add_int_text() - Integer text input
  • add_float_text() - Float text input
  • add_bounded_int_text() - Validated integers
  • add_bounded_float_text() - Validated floats

✅ Selection

  • add_check() - Checkbox/Yes-No
  • add_dropdown() - Selection from list

🎨 Display

  • add_label() - Static text/headers

Value Persistence & Configuration

Automatic Memory

# First run
gui = EZInput("analysis")
threshold = gui.add_float_range("thresh", "Threshold:", 0, 1)
gui.show()
# User enters 0.75

# Second run (tomorrow)
gui = EZInput("analysis")
threshold = gui.add_float_range("thresh", "Threshold:", 0, 1)
gui.show()
# Default is now 0.75! ✨

Save & Load Configs

# Save current parameters
gui.save_parameters("optimal_params.yml")

# Load saved parameters
gui.load_parameters("optimal_params.yml")

# Share with team!
# Config saved to: ~/.ezinput/optimal_params.yml

⚙️ Value Priority Order

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

Resources & Support

🔧 API Reference

Complete method documentation

Read API Docs →

💬 GitHub Issues

Report bugs or request features

Open an Issue →

✉️ Contact

Email the development team

Get in Touch →