Frontend Moduleο
The frontend module contains the Tkinter-based graphical user interface.
Image Utilitiesο
Shared image loading and scaling for the Tkinter frontend.
- frontend.image_utils.plot_display_path(output_path)[source]ο
Return the path to use for displaying a plot in the GUI.
When the saved file is PDF, returns the
_preview.pngpath if it exists, so Tkinter can show the image without breaking.- Parameters:
output_path β Full path to the saved plot file (e.g. PDF or PNG).
- Returns:
Path to the image file to display (preview PNG for PDFs when available).
- frontend.image_utils.preview_path_to_remove_after_display(display_path, original_output_path)[source]ο
Return the path of an auxiliary preview file to remove after display.
If the displayed image is an auxiliary preview file (
_preview.png), return its path so the caller can delete it after the window is closed.- Parameters:
display_path β Path actually used for display (may be preview PNG).
original_output_path β Original output path (e.g. PDF path).
- Returns:
Path to the preview file to delete, or None if no cleanup needed.
- frontend.image_utils.load_image_scaled(path, max_width, max_height)[source]ο
Load an image from file and return a Tk PhotoImage scaled to fit within max dimensions.
Uses PIL when available. Supports PNG, JPG, JPEG. Returns None if the file cannot be opened (e.g. missing PIL), so callers can fall back to tkinter.PhotoImage(file=path) for raster formats or skip showing.
- Parameters:
path β Path to the image file.
max_width β Maximum width in pixels.
max_height β Maximum height in pixels.
- Returns:
ImageTk.PhotoImage scaled to fit, or None on failure.
Window Positioningο
Utilities for Tkinter window positioning.
- frontend.window_utils.place_window_centered(win, width=None, height=None, *, preserve_size=False, max_width=900, max_height=650, max_width_ratio=0.7, max_height_ratio=0.7)[source]ο
Position a Toplevel window centered on screen.
- Parameters:
win β The Toplevel window to position.
width β Desired width in pixels. If None and not preserve_size, uses computed size.
height β Desired height in pixels. If None and not preserve_size, uses computed size.
preserve_size β If True, keeps the windowβs current size and only sets position. Call after widgets are packed/gridded and after win.update_idletasks().
max_width β Cap for width when computed from screen (default 900).
max_height β Cap for height when computed from screen (default 650).
max_width_ratio β Max width as fraction of screen when width is None.
max_height_ratio β Max height as fraction of screen when height is None.
Dialogsο
Main dialogs package (re-exports from ui_dialogs submodules).
UI Dialogs package. Contains all Tkinter dialog windows for user interaction, split by concern.
Load Data Dialogο
Load data dialog using native file picker (replaces ask_file_type + ask_file_name).
- frontend.ui_dialogs.load_data_dialog.open_load_dialog(parent)[source]ο
Open native file dialog to select a data file (CSV, TXT, XLSX).
Replaces the two-step flow (file type + file name) with a single native OS dialog. Works on Windows, Linux, and macOS.
- Parameters:
parent β Parent Tkinter window (Toplevel or Tk).
- Returns:
Tuple (file_path, file_type) if user selects a file, or (None, None) if user cancels. file_type is one of βcsvβ, βtxtβ, βxlsxβ.
Save Data Dialogο
Save data dialog for the data view window.
Data Selection Dialogο
Data selection dialogs: variables and data preview.
- frontend.ui_dialogs.data_selection.ask_variables(parent_window, variable_names)[source]ο
Dialog to select independent (x) and dependent (y) variables and plot name.
- Parameters:
parent_window β Parent Tkinter window.
variable_names β List of available variable names from the dataset.
- Returns:
Tuple of
(x_name, y_name, plot_name). Returns('', '', '')if user cancels.
- frontend.ui_dialogs.data_selection.ask_multiple_x_variables(parent_window, variable_names, num_vars, first_x_name)[source]ο
Dialog to select multiple independent (x) variables for multidimensional fitting.
- Parameters:
parent_window β Parent Tkinter window.
variable_names β List of available variable names from the dataset.
num_vars β Number of independent variables to select.
first_x_name β Name of the first x variable already selected.
- Returns:
List of x variable names. Returns empty list if user cancels.
- frontend.ui_dialogs.data_selection.show_data_dialog(parent_window, data)[source]ο
Dialog to display loaded data.
Provides transform, cleaning, save, and pair-plot options. Transform/clean dialogs are non-modal so focus stays on the data window for multiple ops. Pair plots auto-update when data is transformed (if already open).
- Parameters:
parent_window β Parent Tkinter window (
TkorToplevel).data β DataFrame to display (or string). If DataFrame, converted to string for display using
to_string()method.
Equation Dialogο
Equation and parameter dialogs for fitting.
- frontend.ui_dialogs.equation.ask_equation_type(parent_window)[source]ο
Dialog to select fitting equation type.
Optionally allows configuring initial values and bounds per parameter. Displays a grid of buttons for predefined equation types, plus options for custom equations and exiting.
- Parameters:
parent_window β Parent Tkinter window.
- Returns:
Tuple of
(equation_type, user_initial_guess, user_bounds).user_initial_guessanduser_boundsareNonewhen not configured.
- frontend.ui_dialogs.equation.ask_num_parameters(parent_window)[source]ο
Dialog to ask for number of parameters and independent variables in a custom function.
Displays a dialog with Spinboxes allowing the user to select the number of parameters (1-12) and number of independent variables (1-10) for a custom fitting function.
- Parameters:
parent_window β Parent Tkinter window.
- Returns:
Tuple of (number of parameters, number of independent variables), or
Noneif the user closed the window.
- frontend.ui_dialogs.equation.ask_parameter_names(parent_window, num_params)[source]ο
Dialog to ask for parameter names in a custom function.
Displays a series of dialogs (one per parameter) asking the user to enter parameter names. Shows Unicode escape sequence hints for Greek letters. Parameter names are normalized (Unicode escapes replaced, whitespace removed).
- Parameters:
parent_window β Parent Tkinter window.
num_params β Number of parameters to collect names for.
- Returns:
List of parameter names entered by the user. Returns
[EXIT_SIGNAL]if user cancels at any point.
- frontend.ui_dialogs.equation.ask_custom_formula(parent_window, parameter_names, num_independent_vars=1)[source]ο
Dialog to ask for custom function formula.
Displays a dialog allowing the user to enter a mathematical formula using the previously defined parameter names. Shows syntax hints and Unicode escape sequence reference for Greek letters.
- Parameters:
parent_window β Parent Tkinter window.
parameter_names β List of parameter names that can be used in the formula.
num_independent_vars β Number of independent variables (1 for x, >1 for x_0, x_1, etc.).
- Returns:
Formula string entered by the user, with Unicode escape sequences normalized. Returns
EXIT_SIGNALif user cancels.
- frontend.ui_dialogs.equation.ask_num_fits(parent_window, min_val=2, max_val=10)[source]ο
Dialog to ask for number of multiple fits.
Displays a dialog with a Spinbox allowing the user to select the number of fits to perform (between min_val and max_val).
- Parameters:
parent_window β Parent Tkinter window.
min_val β Minimum number of fits allowed (default: 2).
max_val β Maximum number of fits allowed (default: 10).
- Returns:
Selected number of fits (between
min_valandmax_val), orNoneif the user closed the window.
Help Dialogο
Help dialog and text utilities for Tkinter display.
- frontend.ui_dialogs.help.remove_markdown_bold(text)[source]ο
Remove Markdown bold markers (**) from text for Tkinter display.
Only strips ** when the content between them has no asterisk, so exponentiation in code (e.g.
x**2) is preserved.- Parameters:
text β String that may contain Markdown bold markers.
- Returns:
String with
**...**removed (content preserved).
- frontend.ui_dialogs.help.show_data_view_help_dialog(parent_window)[source]ο
Display help dialog for the Watch Data window (transform, clean, save options).
Shows collapsible sections: pair plots, transform (with each option detailed), clean (with each option detailed), and save. Used when the user clicks Help in the data view.
- Parameters:
parent_window β Parent Tkinter window (the data view Toplevel).
- frontend.ui_dialogs.help.show_help_dialog(parent_window)[source]ο
Display help and information dialog about the application.
Shows information in collapsible sections (like the config dialog): objective, advantages, fitting modes, custom functions, data format, data location, output location, and statistics.
- Parameters:
parent_window β Parent Tkinter window (
TkorToplevel).
Configuration Dialogο
Configuration dialog for editing .env settings.
- frontend.ui_dialogs.config_dialog.show_config_dialog(parent_window)[source]ο
Show configuration dialog to edit .env fields.
Pre-fills with current env values (or defaults). On Accept, writes .env and returns True so the caller can restart the app. On Cancel returns False.
- Parameters:
parent_window β Parent Tkinter window (
TkorToplevel).- Returns:
Trueif user accepted and.envwas written (caller should restart).Falseif user cancelled.
Result Dialogο
Result window for displaying fitting results and plot.
- frontend.ui_dialogs.result.create_result_window(fit_name, text, equation_str, output_path, figure_3d=None, fit_info=None)[source]ο
Create a Tkinter window to display the fitting results.
Creates a new
Toplevelwindow showing the fitting results including parameter values, uncertainties, statistics, and the fitted equation plot.- Parameters:
fit_name β Name of the fit for window title.
text β Formatted text with parameters, uncertainties, and statistics.
equation_str β Formatted equation string with parameter values.
output_path β Path to the plot image file to display.
figure_3d β Optional matplotlib Figure for 3D plot (embeds interactive canvas, rotatable with mouse).
fit_info β Optional dict with βfit_funcβ, βparamsβ, βcovβ, βx_namesβ for prediction feature.
- Returns:
The created
Toplevelwindow instance.
Tooltipο
Tooltip binding for Tkinter widgets.
- frontend.ui_dialogs.tooltip.bind_tooltip(widget, text, delay_ms=500)[source]ο
Bind a tooltip to a Tkinter widget.
Shows a tooltip window after a delay when the mouse enters the widget, and hides it when the mouse leaves. Uses a contrasting background and border so the tooltip is visible over the UI.
- Parameters:
widget β Tkinter widget to bind the tooltip to.
text β Tooltip text to display when mouse hovers over the widget.
delay_ms β Delay in milliseconds before showing the tooltip (default:
500).