Skip to content

Commit 05e8429

Browse files
committed
ENH: Re-introduce Qt resource support in Python
This commit re-introduces the support removed in c91fa78 (COMP: Remove unused python-based Qt resource file). It also ensures that the resources are available through Qt resource system by importing the corresponding module. This is particularly relevant when styling application through qss stylesheet where icons can be referenced setting attribute like the following: image: url(":/Icons/Image.svg"); The "Gears.png" icon is added only for the sake of testing the generation of the python-based Qt resource file and may be removed after populating the file.
1 parent f373eef commit 05e8429

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

{{cookiecutter.project_name}}/Modules/Scripted/Home/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@ set(MODULE_PYTHON_RESOURCES
1414
Resources/Home.qss
1515
)
1616

17+
slicerFunctionAddPythonQtResources(MODULE_PYTHON_QRC_RESOURCES
18+
Resources/${MODULE_NAME}.qrc
19+
)
20+
1721
#-----------------------------------------------------------------------------
1822
slicerMacroBuildScriptedModule(
1923
NAME ${MODULE_NAME}
20-
SCRIPTS ${MODULE_PYTHON_SCRIPTS}
24+
SCRIPTS ${MODULE_PYTHON_SCRIPTS} ${MODULE_PYTHON_QRC_RESOURCES}
2125
RESOURCES ${MODULE_PYTHON_RESOURCES}
2226
)
2327

{{cookiecutter.project_name}}/Modules/Scripted/Home/Home.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
import SlicerCustomAppUtilities
1212

13+
# Import to ensure the files are available through the Qt resource system
14+
from Resources import HomeResources
15+
1316

1417
class Home(ScriptedLoadableModule):
1518
"""The home module allows to orchestrate and style the overall application workflow.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE RCC>
2+
<!--
3+
This file was automatically generated by genqrc.py ['./Icons/']
4+
See http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/Build_system/Qt_resource_files for more information.
5+
-->
6+
7+
<RCC version="1.0">
8+
9+
<qresource prefix="Icons">
10+
<file alias="Gears.png">./Icons/Gears.png</file>
11+
</qresource>
12+
13+
</RCC>

0 commit comments

Comments
 (0)