Skip to content

Commit

Permalink
Resource access example added.
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank Blankenburg committed Jan 26, 2023
1 parent ad2d88d commit c7439a2
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Resource access example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

Demonstration for accessing add-on based resources via scripts.
Binary file added Resource access example/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions Resource access example/metainfo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"author": "Carl Zeiss GOM Metrology GmbH",
"description": "Examples for accessing add-on based resources",
"licensing": {
"licenses": [
],
"product-codes": [
]
},
"software-revision": "157350",
"software-version": "GOM Software 2022 Service Pack 2",
"title": "Resource access example",
"uuid": "040e602d-40d6-47a1-9fb4-e558b231ada9",
"version": "1.0.0"
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions Resource access example/scripts/Resources/dialog.gdlg
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"content": [
[
{
"columns": 1,
"data": "AAAAAA==",
"file_name": "",
"height": 0,
"keep_aspect": true,
"keep_original_size": true,
"name": "image",
"rows": 1,
"system_image": "system_message_warning",
"tooltip": {
"id": "",
"text": "",
"translatable": true
},
"type": "image",
"use_system_image": false,
"width": 0
}
]
],
"control": {
"id": "Close"
},
"embedding": "",
"position": "",
"size": {
"height": 140,
"width": 213
},
"sizemode": "",
"style": "",
"title": {
"id": "",
"text": "Display image",
"translatable": true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"modules": [
],
"uuid": "47f9a632-8410-4143-8608-2d5908309e84",
"wheelsfrom": "local"
}
13 changes: 13 additions & 0 deletions Resource access example/scripts/Resources/resource.metainfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"display_name": "resource",
"icon": "",
"iinspect_condition": "",
"interactive": false,
"multicreation_script": false,
"name": "resource",
"script_check_type": "none",
"script_element_type": "none",
"show_in_iinspect": false,
"show_in_menu": true,
"uuid": "6035f426-b00d-4b6d-bd89-4fc3689f451b"
}
29 changes: 29 additions & 0 deletions Resource access example/scripts/Resources/resource.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
#
# This script demonstrates reading asset or resource data from a package
#

import gom

#
# Resources are addressed with a relative or absolute file system path
#
data = gom.app.resource["assets/zeiss_logo.png"]

print ('Type:', type (data))
print ('Size:', len (data))

#
# 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=gom.script.sys.create_user_defined_dialog (file='dialog.gdlg')

DIALOG.image.data = data

#
# After dialog setup, it can be displayed.
#
gom.script.sys.show_user_defined_dialog (dialog=DIALOG)


0 comments on commit c7439a2

Please sign in to comment.