Synaptipy Styling Guide
This document describes the Qt6 palette theming, button role conventions, and PyQtGraph plot styling utilities used across Synaptipy.
Overview
Synaptipy separates application palette management (src/synaptipy/shared/theme_manager.py)
from widget and plot helper utilities (src/synaptipy/shared/styling.py and
src/synaptipy/shared/plot_factory.py):
Theme Manager (
theme_manager.py) selects the appropriate native or cross-platform Qt widget style per OS ("macOS"+NSAppearanceon macOS,"windows11"/"windowsvista"/"Fusion"on Windows, and"Breeze"/"Adwaita"/"Fusion"on Linux), applies matchingQPaletteand semantic QSS rules, and tracks OS color-scheme changes (including GNOME, GTK, and KDE preferences on Linux) whenThemeMode.SYSTEMis selected.Plot Factory (
plot_factory.py) constructs allPyQtGraphplot widgets and layout containers with safe software-rendering defaults and scientific axes formatting.Styling Helpers (
styling.py) provide semantic button/label helpers and theme-awarePyQtGraphpens.
Theme Mode Management
Application theme state is managed in src/synaptipy/shared/theme_manager.py:
ThemeMode: Enum withLIGHT,DARK, andSYSTEMmodes.get_theme_mode(): Returns the persistedThemeModefromQSettings.set_theme_mode(mode): PersistsmodetoQSettingsand emitstheme_changed.apply_theme(mode=None): Resolvesselect_platform_style(...), applies the light or dark palette/appearance foris_dark_mode(), and emitstheme_changedafter updatingQApplication.install_system_theme_listener(app): Connects toQStyleHints.colorSchemeChangedsoThemeMode.SYSTEMupdates live when the OS switches between light and dark appearance.
from synaptipy.shared.theme_manager import ThemeMode, apply_theme, set_theme_mode
# Persist dark mode preference and apply immediately
set_theme_mode(ThemeMode.DARK, emit_signal=False)
apply_theme(ThemeMode.DARK)
# Re-apply the currently saved preference at startup
apply_theme()
Scientific trace canvases keep a white ("#ffffff") background with black
foreground axes (configure_plot_widget) regardless of whether the surrounding
UI chrome uses a dark or light theme, ensuring publication-consistent contrast.
Creating and Styling PyQtGraph Plots
Direct instantiation of pg.PlotWidget() or pg.GraphicsLayoutWidget() is
forbidden because unguarded OpenGL/ViewBox configurations cause platform-specific
crashes. Always construct plot widgets through SynaptipyPlotFactory:
from synaptipy.shared.plot_factory import SynaptipyPlotFactory
from synaptipy.shared.styling import configure_plot_widget, get_average_pen, get_trial_pen
plot_widget = SynaptipyPlotFactory.create_plot_widget(
title="Membrane Potential",
labels={"left": ("Voltage", "mV"), "bottom": ("Time", "s")},
)
configure_plot_widget(plot_widget)
plot_widget.plot(time, trial_data, pen=get_trial_pen())
plot_widget.plot(time, avg_data, pen=get_average_pen())
User-configurable trace, scatter, and overlay pens are managed through
get_plot_customization_manager() (src/synaptipy/shared/plot_customization.py),
accessible in the UI under View > Plot Customization….