{"id":20215492,"url":"https://github.com/kitwaremedical/slicercustomapputilities","last_synced_at":"2026-06-07T17:33:08.811Z","repository":{"id":143102817,"uuid":"592460994","full_name":"KitwareMedical/SlicerCustomAppUtilities","owner":"KitwareMedical","description":"Specialized Slicer modules and scripts to support development of custom 3D Slicer application","archived":false,"fork":false,"pushed_at":"2023-04-06T17:55:02.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":14,"default_branch":"main","last_synced_at":"2025-02-24T07:06:51.578Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"CMake","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KitwareMedical.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-23T19:28:17.000Z","updated_at":"2023-04-06T17:55:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"2a6b1a03-971e-476d-8a0e-28baf3a6cf6a","html_url":"https://github.com/KitwareMedical/SlicerCustomAppUtilities","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KitwareMedical%2FSlicerCustomAppUtilities","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KitwareMedical%2FSlicerCustomAppUtilities/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KitwareMedical%2FSlicerCustomAppUtilities/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KitwareMedical%2FSlicerCustomAppUtilities/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KitwareMedical","download_url":"https://codeload.github.com/KitwareMedical/SlicerCustomAppUtilities/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241652964,"owners_count":19997578,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T06:22:37.686Z","updated_at":"2026-06-07T17:33:08.270Z","avatar_url":"https://github.com/KitwareMedical.png","language":"CMake","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SlicerCustomAppUtilities by Kitware\n\nSpecialized Slicer modules and scripts to support development of [custom 3D Slicer application](https://github.com/KitwareMedical/SlicerCustomAppTemplate).\n\nAt [Kitware](https://www.kitware.com), we help customers develop commercial products based on 3D Slicer and we have used the platform to rapidly prototype solutions in nearly every aspect of medical imaging.\n\n## Slicer custom application integration\n\nA snippet like the following should be added in the custom application `CMakeLists.txt`\n\nMake sure to replace `\u003cSHA\u003e` with a valid value.\n\nNote the explicit path appended to `Slicer_EXTENSION_SOURCE_DIRS`.\n\n```\n# Add remote extension source directories\n\n# SlicerCustomAppUtilities\nset(extension_name \"SlicerCustomAppUtilities\")\nset(${extension_name}_SOURCE_DIR \"${CMAKE_BINARY_DIR}/${extension_name}\")\nFetchContent_Populate(${extension_name}\n  SOURCE_DIR     ${${extension_name}_SOURCE_DIR}\n  GIT_REPOSITORY https://github.com/KitwareMedical/SlicerCustomAppUtilities.git\n  GIT_TAG        \u003cSHA\u003e\n  GIT_PROGRESS   1\n  QUIET\n  )\nmessage(STATUS \"Remote - ${extension_name} [OK]\")\nlist(APPEND Slicer_EXTENSION_SOURCE_DIRS ${${extension_name}_SOURCE_DIR}/Modules/Scripted/SlicerCustomAppUtilities)\n```\n\n## Styling\n\n### Stylesheet\n\nThe custom application Qt stylesheet may be defined in a single `Home.qss` file.\n\nCorresponding stylesheet may be applied to the application (`slicer.app`) during module initialization using the `SlicerCustomAppUtilities.applyStyle()` function.\n\nCSS rules should be organized in the stylesheet files from the most general to the most specific rules. Use of `/* */` comment is recommended to group the rules.\n\n```\n/*  General styling */\n\n/* Light colors */\n\n/* Dark colors */\n```\n\nReferences:\n* https://doc.qt.io/qt-5/stylesheet.html\n* https://doc.qt.io/qt-5/stylesheet-syntax.html\n\n### The `cssClass` dynamic Qt property\n\nWhen styling of widgets should be dynamically updated based on the application current state, the relevant states may be described using CSS classes.\n\nIn the context of Slicer custom application, CSS classes may be associated with the Qt dynamic property called `cssClass`.\n\nThese class names may be set/added/removed from a specific Qt widget using `setCssClass/addCssClass/removeCssClass` functions available in the `SlicerCustomAppUtilities` Python module.\n\nFor example, styling of `QPushButton` based on a \"CSS\" class called `widget--color-light` associated with one of its ancestors may be done doing the following:\n\n```\nQWidget[cssClass~=\"widget--color-light\"] QPushButton {\n    background-color: #666666;\n}\n```\n\nSee references below to learn more about the `[attr~=value]` syntax.\n\nAfter setting, adding or removing CSS class, the function `SlicerCustomAppUtilities.polish()` should be called to ensure the stylesheet is re-applied to consider the updated `cssClass` property.\n\nReferences:\n* https://doc.qt.io/qt-5/properties.html#dynamic-properties\n* https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors#syntax\n\n### CSS class naming convention\n\nThe naming convention based on BEM (Block, Element, Modifier) may be used.\n\nIn the example below, the classes `widget--color-light` and `widget--color-dark` are used where\n* `widget` is the `Block`\n* `color` is the `Element`\n* `light` or `dark` are the `Modifier`\n\n```\n/* General styling */\nQWidget {\n    background-color: #2a2a2a;\n    color: #B7B7B7;\n}\n\nQPushButton {\n    background-color: #434343;\n}\n\n/* Light colors */\nQWidget[cssClass~=\"widget--color-light\"] QWidget {\n    background-color: #434343;\n}\n\nQWidget[cssClass~=\"widget--color-light\"] QPushButton {\n    background-color: #666666;\n}\n\n/* Dark colors */\nQWidget[cssClass~=\"widget--color-dark\"] QWidget {\n    background-color: #2a2a2a;\n}\n\nQWidget[cssClass~=\"widget--color-dark\"] QPushButton {\n    background-color: #434343;\n}\n```\n\nReferences:\n* https://getbem.com/naming/\n\n## CMake Modules\n\n### DownloadGitHubReleaseAsset\n\nDownload a GitHub release asset.\n\nThe module can be used when running in cmake -P script mode and it requires\nthe environment variable `GITHUB_TOKEN` to be set.\n\nFor example:\n\n```cmake\n  set(EP_DOWNLOAD_DIR ${CMAKE_BINARY_DIR})\n  set(EP_SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj})\n\n  set(asset_filename \"\u003cassetname\u003e\")\n  set(asset_sha256 \"\u003cassetsha256\u003e\")\n\n  # The CMake function _ep_write_extractfile_script is internally provided by the\n  # ExternalProject CMake module.\n  if(NOT COMMAND _ep_write_extractfile_script)\n    message(FATAL_ERROR \"_ep_write_extractfile_script CMake function is not available\")\n  endif()\n  _ep_write_extractfile_script(\n    \"${EP_DOWNLOAD_DIR}/${proj}-extract-archive.cmake\" # script_filename\n    \"${proj}\" # name\n    \"${EP_DOWNLOAD_DIR}/${asset_filename}\" # filename\n    \"${EP_SOURCE_DIR}\" # directory\n    \"\" # options (introduced in CMake 3.24 through Kitware/CMake@a283e58b5)\n    )\n\n  ExternalProject_Add(${proj}\n    ${${proj}_EP_ARGS}\n    DOWNLOAD_DIR ${EP_DOWNLOAD_DIR}\n    DOWNLOAD_COMMAND ${CMAKE_COMMAND}\n      -DGITHUB_ORG:STRING=\u003corganization\u003e\n      -DGITHUB_REPO:STRING=\u003crepository\u003e\n      -DGITHUB_RELEASE:STRING=\u003creleasename\u003e\n      -DGITHUB_ASSET_FILENAME:STRING=${asset_filename}\n      -DEXPECTED_SHA256:STRING=${asset_sha256}\n      -DOUTPUT_DIR:STRING=${EP_DOWNLOAD_DIR}\n      -P ${SlicerCustomAppUtilities_SOURCE_DIR}/CMake/DownloadGitHubReleaseAsset.cmake\n    COMMAND ${CMAKE_COMMAND}\n      -P \"${EP_DOWNLOAD_DIR}/${proj}-extract-archive.cmake\"\n    SOURCE_DIR ${EP_SOURCE_DIR}\n    BUILD_IN_SOURCE 1\n    CONFIGURE_COMMAND \"\"\n    BUILD_COMMAND \"\"\n    INSTALL_COMMAND \"\"\n    DEPENDS\n      ${${proj}_DEPENDS}\n    )\n  set(${proj}_DIR ${EP_SOURCE_DIR})\n```\n\nwhere the following placeholders would need to be updated:\n\n```\n\u003cassetname\u003e\n\u003cassetsha256\u003e\n\u003corganization\u003e\n\u003crepository\u003e\n\u003creleasename\u003e\n```\n\n## License\n\nThis project template is distributed under the Apache 2.0 license. Please see\nthe *LICENSE* file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkitwaremedical%2Fslicercustomapputilities","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkitwaremedical%2Fslicercustomapputilities","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkitwaremedical%2Fslicercustomapputilities/lists"}