Update GUI assets import#3370
Draft
C-Achard wants to merge 2 commits into
Draft
Conversation
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.
This was referenced Jun 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 andQIcon/QPixmapusage with these new helper functions, making resource management more robust and portable.The most important changes are:
Introduction of centralized GUI asset utilities:
deeplabcut/gui/gui_assets.py, which provides functions such asicon_from_resourceandpixmap_from_resourceto load icons and images from the application's assets directory in a consistent way.Refactoring icon and image loading throughout the GUI:
QIcon,QPixmap, and file path manipulations for loading icons and images with the new utility functions in all relevant GUI files, includingcomponents.py,launch_script.py,tabs/create_project.py,tabs/modelzoo.py,tabs/open_project.py,tabs/train_network.py, andwindow.py. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21] [22] [23]Code cleanup and simplification:
These changes improve maintainability, portability, and reliability of the GUI resource handling.