frontend – GUI
Frontend module for DifferentialLab.
- class frontend.MainMenu(root)[source]
Bases:
objectApplication main menu window.
Presents five actions: Solve, Function Transform, Information, Configuration, Quit.
- Parameters:
root (
Tk) – The root Tk window.
frontend.theme
TTK theme configuration built from environment variables.
- frontend.theme.get_contrast_foreground(bg_color)[source]
Return a foreground color with high contrast against the given background.
Uses luminance to choose black or white for maximum readability.
- frontend.theme.get_select_colors(element_bg, text_fg)[source]
Compute select background and foreground from element colors.
Selected text: 20% lighter than unselected text. Selected background: 25% darker than the element’s background.
frontend.window_utils
Window management utilities for Tkinter.
- frontend.window_utils.center_window(window, width=None, height=None, *, preserve_size=False, max_width_ratio=0.85, max_height_ratio=0.85, resizable=False, y_offset_up=40)[source]
Center window on the screen.
When preserve_size is
Truethe window is sized to its requested (content-driven) dimensions instead of the supplied width/height. Maximum dimensions are clamped to max_width_ratio / max_height_ratio of the screen.- Parameters:
window (
Tk|Toplevel) – The Tk or Toplevel window.width (
int|None) – Desired minimum width (ignored when preserve_size is set).height (
int|None) – Desired minimum height (ignored when preserve_size is set).preserve_size (
bool) – Use the widget-requested size instead of explicit dims.max_width_ratio (
float) – Max fraction of screen width.max_height_ratio (
float) – Max fraction of screen height.resizable (
bool) – Whether the window can be resized by the user.y_offset_up (
int) – Pixels to shift the window up from center (avoids bottom overflow).
- Return type:
- frontend.window_utils.fit_and_center(window, min_width=400, min_height=300, padding=40, *, max_ratio=0.9, **center_kwargs)[source]
Size window to fit its content (with minimums) and center it.
Computes dimensions from the window’s requested size, clamps to
[min_width, screen * max_ratio], then delegates tocenter_window().- Parameters:
window (
Tk|Toplevel) – The Tk or Toplevel window.min_width (
int) – Minimum window width in pixels.min_height (
int) – Minimum window height in pixels.padding (
int) – Extra pixels added to the requested size.max_ratio (
float) – Maximum fraction of the screen for each dimension.**center_kwargs (
object) – Forwarded tocenter_window().
- Return type:
- frontend.window_utils.make_modal(dialog, parent)[source]
Make a Toplevel dialog modal relative to parent.
- frontend.window_utils.bind_wraplength(frame, label_or_labels, pad=20, min_wrap=200, debounce_ms=50)[source]
Bind label(s) wraplength to the width of a frame.
Automatically adjusts wraplength when the frame is resized, ensuring text wraps nicely within the available space. Supports debouncing to avoid excessive updates during rapid resize.
- Parameters:
frame (
Widget) – The frame whose width determines the wraplength.label_or_labels (
Widget|list[Widget]) – Single label widget or list of labels to update.pad (
int) – Padding in pixels to subtract from frame width.min_wrap (
int) – Minimum wraplength in pixels.debounce_ms (
int) – Debounce delay for Configure events (0 = no debounce).
- Return type:
frontend.plot_embed
Tkinter embedding utilities for matplotlib figures.
- frontend.plot_embed.embed_animation_plot_in_tk(fig, parent, *, on_export_mp4=None)[source]
Embed an animation figure with Scale, Play button, duration entry, and Export MP4.
The figure must have _animation_update(idx) and _animation_n_points attributes. Duration (seconds) controls both playback speed and MP4 export length.
frontend.ui_dialogs
UI dialog modules for DifferentialLab.
Set up arrow-key and Enter navigation on a 2-D grid of widgets.
- class frontend.ui_dialogs.ToolTip(widget, text, delay=None)[source]
Bases:
objectHover tooltip for any Tkinter widget.
frontend.ui_dialogs.equation_dialog
Equation selection dialog — choose predefined or write custom ODE.
frontend.ui_dialogs.parameters_dialog
Parameters dialog — configure domain, ICs, method, and statistics.
- class frontend.ui_dialogs.parameters_dialog.ParametersDialog(parent, *, expression=None, function_name=None, order, parameters, equation_name, default_y0, default_domain, parameters_schema=None, display_formula=None, equation_type='ode', variables=None, vector_expressions=None, vector_components=1, pde_operator='neg_laplacian', component_orders=None)[source]
Bases:
objectDialog for configuring solver parameters, ICs, and statistics.
- Parameters:
parent (
Tk|Toplevel) – Parent window.function_name (
str|None) – Name of function in config.equations (optional).order (
int) – ODE order.parameters (
dict[str,float]) – Parameter name-value mapping.equation_name (
str) – Display name.display_formula (str | None)
equation_type (str)
vector_components (int)
pde_operator (str)
frontend.ui_dialogs.result_dialog
Result dialog — left panel (stats, info, export) + right panel (interactive plots).
- class frontend.ui_dialogs.result_dialog.ResultDialog(parent, *, result)[source]
Bases:
objectWindow showing the solution with interactive plot tabs.
Plots are generated on-demand from the raw solver data. The user selects what to visualise (derivatives, phase-space axes, etc.) inside the result window rather than before solving.
- Parameters:
parent (
Tk|Toplevel) – Parent window.result (
SolverResult) – A data-onlySolverResultfrom the pipeline.
frontend.ui_dialogs.config_dialog
Configuration dialog — edit .env variables with collapsible sections.
frontend.ui_dialogs.loading_dialog
Loading dialog shown while the solver runs.
frontend.ui_dialogs.help_dialog
Help / Information dialog with collapsible sections.
frontend.ui_dialogs.scrollable_frame
Reusable scrollable frame widget with cross-platform mousewheel and keyboard support.
- class frontend.ui_dialogs.scrollable_frame.ScrollableFrame(parent, **kwargs)[source]
Bases:
FrameA frame that wraps a Canvas + Scrollbar + inner Frame.
Children should be packed/gridded inside
self.inner.- Parameters:
parent (
Widget) – Parent widget.**kwargs – Extra keyword arguments forwarded to the outer
ttk.Frame.
frontend.ui_dialogs.collapsible_section
Reusable collapsible section widget for Tkinter dialogs.
- class frontend.ui_dialogs.collapsible_section.CollapsibleSection(parent, scroll, title, *, expanded=False, pad=6)[source]
Bases:
objectA header bar that toggles the visibility of an inner content frame.
Usage:
section = CollapsibleSection(parent, scroll, "Title", expanded=True) ttk.Label(section.content, text="Hello").pack()
- Parameters:
parent (
Frame) – Parent widget to pack into.scroll (
ScrollableFrame) – TheScrollableFramethat hosts the section (used to refresh the scroll region and rebind mousewheel events).title (
str) – Section header text.expanded (
bool) – Whether the section starts open.pad (
int) – Vertical padding above the wrapper.
frontend.ui_dialogs.tooltip
Tooltip widget for Tkinter/ttk elements.
frontend.ui_dialogs.transform_dialog
Transform dialog — enter function, apply Fourier/Laplace/Taylor, visualize and export.