SIGN IN SIGN UP

Fix PySide6 stylesheet usage (#3371)

* fix path resolution on network drives. Replace  Path(..).resolve() with Path(..).absolute()

* Add safe_resolve helper for path resolution

* fix redundant resolution of resolved path in memory_replay.py

* fix open -> os.stat

* replace os.stat -> open for files, listdir for dirs.

* fix TestReadConfigProjectPath

* Update deeplabcut/utils/auxiliaryfunctions.py

* Adjust config path tests for Path objects

Update `test_auxiliaryfunctions.py` to assert `project_path` as a `pathlib.Path` instead of a string. The tests now cast to `str` only for the `"Volume{"` check, use `.exists()` for filesystem validation, and compare against `project_dir.absolute()` directly.

* address remaining `.resolve()` cases: prefer `.absolute()`, or otherwise `safe_resolve()`

* update `safe_resolve`: add logging, use os.stat (more efficient)

* update test safe_resolve: allow fallback and test open/closing instead

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* fix remaining Path.resolve()

* Add GUI asset helper utilities

Introduce deeplabcut.gui.gui_assets module providing utilities to load bundled GUI assets. It locates the package assets directory via importlib.resources, and exposes resource_bytes, resource_text, get_assets_dir, get_style_qss, pixmap_from_resource and icon_from_resource helpers (using PySide6 QPixmap/QIcon). Includes error handling when image data cannot be loaded and uses type annotations for clarity.

* Use gui_assets for icons and pixmaps

Replace direct filesystem asset loading (BASE_DIR/assets and manual Path lookups) with centralized gui_assets helpers (icon_from_resource, pixmap_from_resource, get_style_qss/get_assets_dir) across multiple GUI modules. Updated imports and calls in components, launch_script, create_project, modelzoo, open_project, train_network, and window to use the new resource functions and remove redundant logo path handling, improving resource access and packaging robustness.

* Use get_style_qss and update qdarkstyle deps

Load the GUI stylesheet via get_style_qss (from gui_assets) instead of reading BASE_DIR/style.qss, and switch qdarkstyle to the PySide6 loader. Also adjust pyproject.toml to declare qdarkstyle for non-Linux x86_64 platforms and pin qdarkstyle==3.1 only for Linux x86_64 (matching the conditional pyside6 pin). This centralizes style handling in gui_assets and aligns the qdarkstyle loader and dependency constraints with PySide6 usage.

* Update uv.lock

* Fallback to PySide2 qdarkstyle stylesheet

Add logging and a try/except around qdarkstyle.load_stylesheet_pyside6() to catch failures and fall back to load_stylesheet_pyside2(). This prevents the app from crashing if the PySide6 stylesheet cannot be loaded and logs a warning with the exception details.

* Remove unused imports and tidy spacing

Cleaned up minor style issues by removing unused `os` imports in GUI tab modules and deleting an extra blank line in `video_processor.py`. This reduces lint noise and keeps the codebase consistent.

* Remove outdated comments

Co-authored-by: Jaap de Ruyter van Steveninck <32810691+deruyter92@users.noreply.github.com>

---------

Co-authored-by: Jaap de Ruyter van Steveninck <32810691+deruyter92@users.noreply.github.com>
Co-authored-by: Jaap de Ruyter <deruyter92@gmail.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
C
Cyril Achard committed
785bcda55eeb1f88dfe416b14e5bf6b8d61620b6
Parent: f10664e
Committed by GitHub <noreply@github.com> on 7/20/2026, 11:40:59 AM