Streamlit Web Application

The streamlit_app module contains the Streamlit-based web interface.

Main Application

Streamlit Application for RegressionLab Web-based interface for curve fitting operations.

streamlit_app.app.main()[source]

Main Streamlit application.

Theme Configuration

Streamlit UI theme from config (same rules as tkinter app).

Uses config.theme.UI_STYLE when available (env + theme.py). Converts color names to hex for CSS via matplotlib. Fallback to config.env only if theme cannot be imported (e.g. headless without tkinter).

streamlit_app.theme.get_streamlit_theme()[source]

Theme dict from config: prefers config.theme.UI_STYLE (env + paths + theme), fallback to config.env when theme cannot be imported (e.g. headless).

Returns dict with hex colors and font settings for Streamlit CSS.

streamlit_app.theme.get_main_css(theme)[source]

Generate global Streamlit CSS using theme (same visual rules as tkinter).

Application Sections

The streamlit_app.sections subpackage contains UI sections organized by functionality.

Main Sections Package

Streamlit app sections: sidebar, data, fitting, results, help, modes.

Sidebar Section

Sidebar, session state, and logo for the Streamlit app.

streamlit_app.sections.sidebar.initialize_session_state()[source]

Initialize Streamlit session state variables (language from config env).

streamlit_app.sections.sidebar.cycle_language()[source]

Cycle to the next supported language (es -> en -> de -> es).

streamlit_app.sections.sidebar.setup_sidebar(version)[source]

Setup and render the sidebar with language selector and mode options.

Parameters:

version – Application version string to display in the sidebar.

Returns:

Selected operation mode (e.g. ‘normal_fitting’, ‘watch_data’).

Display application logo or fallback header (colors from config theme).

Data Section

Data loading and display for the Streamlit app.

streamlit_app.sections.data.load_uploaded_file(uploaded_file)[source]

Load data from an uploaded file (CSV, XLSX, or TXT).

Parameters:

uploaded_file – Streamlit UploadedFile object (e.g. from st.file_uploader).

Returns:

DataFrame with loaded data, or None if loading fails.

streamlit_app.sections.data.show_data_with_pair_plots(data, *, key_prefix=None, file_id=None)[source]

Show data in an expander with optional pair plots and data analysis (transform/clean/save).

Parameters:
  • data – DataFrame or data to display.

  • key_prefix – If set (e.g. ‘view_data’), enables transform/clean/save and uses session state for the current data. Required for analysis features.

  • file_id – When key_prefix is set, used to detect file changes. When file_id changes, the displayed data is reset to the new loaded data.

streamlit_app.sections.data.get_temp_output_dir()[source]

Get or create a temporary directory for plots. Uses session-specific temp directory.

streamlit_app.sections.data.get_variable_names(data, filter_uncertainty=True)[source]

Public wrapper for variable names (used by fitting and modes).

Fitting Section

Fitting logic and equation selection UI for the Streamlit app.

streamlit_app.sections.fitting.perform_fit(data, x_name, y_name, equation_name, plot_name, custom_formula=None, parameter_names=None, show_title=None)[source]

Perform curve fitting for the given dataset and equation selection.

This helper wraps the core fitting logic used by the Streamlit UI: it resolves either a predefined fitting function or a custom CustomFunctionEvaluator, computes the fit and generates the corresponding plot.

Parameters:
  • data – Dataset with columns x_name, y_name and optionally their uncertainties u{x_name}, u{y_name}.

  • x_name – Name of the independent variable column.

  • y_name – Name of the dependent variable column.

  • equation_name – Internal equation identifier or 'custom_formula'.

  • plot_name – Base name used for the generated plot.

  • custom_formula – Custom formula string when equation_name is 'custom_formula'.

  • parameter_names – List of parameter names used in custom_formula.

  • show_title – If set, override plot title visibility (from env) for this fit. None uses the value from PLOT_SHOW_TITLE.

Returns:

Dictionary with keys equation_name, parameters, equation, plot_path and plot_name when the fit succeeds, or None if the operation fails or is not supported.

streamlit_app.sections.fitting.select_variables(data, key_prefix='')[source]

Show variable selection widgets and return the chosen variables and plot name.

Parameters:
  • data – Dataset from which variables are extracted.

  • key_prefix – Optional prefix for Streamlit widget keys to avoid clashes.

Returns:

Tuple (x_name, y_name, plot_name) selected by the user.

streamlit_app.sections.fitting.show_equation_selector(equation_types)[source]

Show equation type selector in the sidebar/content area.

Parameters:

equation_types – List of available equation identifiers.

Returns:

Tuple (equation_key, custom_formula, parameter_names) where custom_formula and parameter_names are only populated when the custom‑formula option is selected.

Results Section

Results display for the Streamlit app.

streamlit_app.sections.results.show_results(results)[source]

Display fitting results: equation (formula + formatted) left, params center, stats right; plot; download below.

Help Section

Help and information section for the Streamlit app.

streamlit_app.sections.help_section.show_help_section()[source]

Display help information in an expandable section.

Modes Section

Operation modes: normal, multiple datasets, checker, total fitting, view data.

streamlit_app.sections.modes.mode_view_data(_equation_types)[source]

Handle view-data mode: load file and show data without fitting (like Tkinter ‘Mirar datos’).

streamlit_app.sections.modes.mode_normal_fitting(equation_types)[source]

Handle normal fitting mode (single file, single equation), with optional loop mode.

streamlit_app.sections.modes.mode_multiple_datasets(equation_types)[source]

Handle multiple datasets mode (multiple files, single equation), with loop hint.

streamlit_app.sections.modes.mode_checker_fitting(equation_types)[source]

Handle checker fitting mode (single file, multiple equations).

streamlit_app.sections.modes.mode_total_fitting(equation_types)[source]

Handle total fitting mode (single file, all equations).