Skip to main content

sciwidgets

tests

PySide6 widgets for scientific desktop apps: math labels rendered with LaTeX/mathtext, dialogs, and parameter inputs such as sliders, range sliders and validated number fields.

Sliders demo

Right-click menu, Set Value and Edit Configuration:

Slider interaction

The widgets were written for the Maxwell Bloch Solver and moved into this package so other apps can share them.

Features

  • Math labels: MathLabel renders LaTeX through Matplotlib and scales cleanly as SVG. It uses your system LaTeX when installed and falls back to Matplotlib's mathtext otherwise.
  • Sliders: integer, float, array, range and multi-variable sliders with LaTeX names and units, optional range labels, a default-value marker and a right-click menu (save/reset default, set value, ±inf, edit range and format).
  • Scientific number format: "{:.3S}" displays values as 1.23×10⁴.
  • Validated input: NumericLineEdit checks numbers and limits while typing and marks invalid input with a red frame.
  • Parameter widgets: line edit, combo box and toggle sharing one interface with the sliders (get_value / set_value, get_config / set_config) and name/value columns that line up across a panel.
  • Parameter panels: build groups, columns and tabs of parameter widgets from a JSON-style description, with templates and shared defaults, and read or restore all values as one dict.
  • Plot canvas: Matplotlib panels, twins, legends and markers from a description; data by curve id; a right-click style menu whose changes save as plain data.
  • Dialogs: information, warning, error, question, rich-text and About dialogs.
  • Splash screen: your picture with the app name and version drawn on it, sharp on Retina, and start-up messages from anywhere in the app.

Components

Import Contents Docs
sciwidgets.params (sliders) FloatSlider, IntSlider, ArraySlider, FloatRangeSlider, IntRangeSlider, MultiVariableSlider, SliderFeature Sliders
sciwidgets.params (inputs) ParameterLineEdit, ParameterComboBox, ParameterToggle, NumericLineEdit Parameter widgets
sciwidgets.panel ParameterPage, ParameterTabs, widget_from_spec, register_type Parameter panels
sciwidgets.plot PlotCanvas, CurveSelector, CurveCheckBox Plot canvas
sciwidgets.labels MathLabel, set_latex_enabled Labels
sciwidgets.dialogs show_information, show_warning, show_critical, show_rich_information, show_about_dialog, ask_question Dialogs
sciwidgets.splash SplashScreen, splash_message Splash screen
sciwidgets.window MenuBarController, StatusBarController Window helpers
sciwidgets.style, sciwidgets.formatting apply_sci_style, SciStyle, value_to_text, pretty_sci_text Style and formatting

Install

pip install sciwidgets

Requires Python 3.10+, PySide6 6.5+, Matplotlib and NumPy (installed automatically). A LaTeX installation is optional.

For development, from the repo root:

pip install -e ".[dev]"
pytest

The tests run without a window (Qt's offscreen platform) and take about a second.

Quick start

import sys

from PySide6.QtWidgets import QApplication, QVBoxLayout, QWidget

from sciwidgets.params import FloatRangeSlider, FloatSlider
from sciwidgets.style import apply_sci_style

app = QApplication(sys.argv)
apply_sci_style(app)  # required, see "Style" below

win = QWidget()
layout = QVBoxLayout(win)

t1 = FloatSlider(
    label="T_1", unit=r"\mathrm{ms}",
    min_val=0.1, max_val=10.0, init_val=1.0, val_fmt="{:.2f}",
    min_limit=0.0, min_limit_inclusive=False,
)
band = FloatRangeSlider(
    label=r"\nu", unit=r"\mathrm{GHz}",
    min_val=6.60, max_val=6.75, init_vals=(6.65, 6.70), val_fmt="{:.3f}",
)
layout.addWidget(t1)
layout.addWidget(band)

t1.valueChanged.connect(lambda v: print("T1 =", v))
band.valueChanged.connect(lambda v: print("band =", v["range"]))

win.show()
sys.exit(app.exec())

Labels and units are written in LaTeX math mode, without the $ signs.

Style

The widgets rely on SciStyle, a Fusion-based Qt style, for part of their behaviour: clicking a slider groove moves the handle there, disabled sliders get a flat groove, and invalid numeric input gets a red frame. Apply it once at startup:

from sciwidgets.style import apply_sci_style

apply_sci_style(app, my_app_style_sheet)  # your own rules are appended

Signals

valueChanged, defaultChanged and configChanged are emitted only for user actions (dragging, typing, the context menu, dialogs). Setting values from code with set_value, set_config and similar methods is silent, so loading saved parameters never triggers your handlers. Read the new state with get_value() / get_config() after setting it.

Demos

Each subpackage has a runnable demo:

python -m sciwidgets.labels
python -m sciwidgets.dialogs
python -m sciwidgets.params
python -m sciwidgets.params.sliders
python -m sciwidgets.window
python -m sciwidgets.panel
python -m sciwidgets.plot
python -m sciwidgets.splash

Versions

Releases are Git tags following semantic versioning. Pin an exact tag in your app's requirements, as in the install line above, and move to a newer tag when you are ready to test it.

License

MIT License. See LICENSE.

Author

Vahid Anari · GitHub · LinkedIn

Metadata

Release files for sciwidgets 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sciwidgets 0.7.0
File Size Uploaded
sciwidgets-0.7.0.tar.gz 114.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sciwidgets 0.7.0
File Interpreter ABI Platform
sciwidgets-0.7.0-py3-none-any.whl Python 3 none any Details

Total release size: 239.8 kB

Release files / sciwidgets-0.7.0.tar.gz

Download URL sciwidgets-0.7.0.tar.gz
Size 114.6 kB
Tags Source
SHA-256 checksum
How to use checksums
25eae84b70e51e247468ebbaec9cba1b6547152d72505f4bab9b945d96e5a2aa
BLAKE2b-256 checksum
How to use checksums
196cdf3fbc7714243ad33a8e889d2ce10c4ea456c1b05da3bb2d1565252ea106
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Release files / sciwidgets-0.7.0-py3-none-any.whl

Download URL sciwidgets-0.7.0-py3-none-any.whl
Size 125.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a2bf51eba188b0ee70daaafdd758cc112313d1ae2c6a96ffa0324527e2ac3e06
BLAKE2b-256 checksum
How to use checksums
29313928669b6b0b1ddc3293272cd02db9cf2df2f7c66f1198009fb7c0a08f98
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Release history Release notifications | RSS feed

0.10.3

2 release files

0.10.2

2 release files

0.10.1

2 release files

0.10.0

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.1

2 release files

0.8.0

2 release files

This release

0.7.0 This release

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page