View windows Application in an Ignition Window

That might work. You could put something like this in a gateway timer event script at a rate of every second or so:

import glob
import os

list_of_files = glob.glob('/path/to/folder/*')  # get a list of all files in the folder
latest_file = max(list_of_files, key=os.path.getctime) # filter for only the most recently created file
system.tag.write('latestCameraImagePath', latest_file)

Now you have the path to the latest image in the gateway, but you need to get the actual image bytes to the clients. You could either give them access to read the file directly from the gateway (wouldn’t recommend), or have the gateway read in the image bytes and store them in a tag. For the latter approach, you could setup a ValueChange event script on the path tag that populates a byte array tag:

bytes = system.file.readFileAsBytes(currentValue.value)
system.tag.write(latestCameraImageBytes, bytes)

The last step would be to render those bytes in your client window. For that you could attach the following script to a Timer Component on the vision window:

from javax.swing import ImageIcon

imageComponent = event.source.parent.getComponent("Image")
bytes = system.tag.read(latestCameraImageBytes).value
icon = ImageIcon(bytes)
imageComponent.setIcon(icon)
3 Likes