Skip to content

Update GUI assets import#3370

Draft
C-Achard wants to merge 2 commits into
jaap/pathlib_path_policyfrom
cy/update-gui-assets-imports
Draft

Update GUI assets import#3370
C-Achard wants to merge 2 commits into
jaap/pathlib_path_policyfrom
cy/update-gui-assets-imports

Conversation

@C-Achard

Copy link
Copy Markdown
Collaborator

As part of the efforts for path standardization in #3350, a few GUI assets-related could be improved.

This focuses on image and logo paths and aims to make the importing of these assets safer and more centralized.

Automated summary

This pull request refactors how GUI assets (like icons and images) are loaded and used throughout the DeepLabCut GUI. The main improvement is the introduction of a centralized utility module, gui_assets.py, which provides functions to access resources bundled with the application. This change replaces all previous direct file path constructions and QIcon/QPixmap usage with these new helper functions, making resource management more robust and portable.

The most important changes are:

Introduction of centralized GUI asset utilities:

  • Added a new module, deeplabcut/gui/gui_assets.py, which provides functions such as icon_from_resource and pixmap_from_resource to load icons and images from the application's assets directory in a consistent way.

Refactoring icon and image loading throughout the GUI:

Code cleanup and simplification:

  • Removed redundant imports and file path manipulations related to asset loading, further simplifying the codebase and reducing the risk of path-related errors. [1] [2] [3] [4] [5] [6]

These changes improve maintainability, portability, and reliability of the GUI resource handling.

C-Achard added 2 commits June 15, 2026 10:24
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.
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.
@C-Achard C-Achard self-assigned this Jun 15, 2026
@C-Achard C-Achard added enhancement New feature or request GUI issues relating to GUI labels Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request GUI issues relating to GUI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant