Demonstration for accessing App based resources via scripts.
- Reading a resource
Resources are addressed with a relative or absolute file system path. In this example, the path relative to the Python script file is used:
with gom.Resource("assets/zeiss_logo.png").open() as fh:
data = fh.read()
The equivalent absolute path is :Resources/assets/zeiss_logo.png
.
- An absolute has the prefix
:
- The root folder is
<App>/scripts
- Using an image from a resource
print ('Type:', type (data))
# Output: Type: <class 'bytes'>
print ('Size:', len (data))
# Output: Size: 29387
# [...]
# Use script dialog to display the resource as an image. The 'data' field of
# the image widget expects a displayable byte object and will render it.
DIALOG.image.data = data
# [...]