Skip to content

Latest commit

 

History

History
42 lines (27 loc) · 1.09 KB

File metadata and controls

42 lines (27 loc) · 1.09 KB

ResourceAccess

Demonstration for accessing App based resources via scripts.

Highlights

  1. 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
  1. 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

# [...]

See also