简体   繁体   中英

Is there a way to generate windows and/or components in Ignition?

I was hoping that Ignition had a way to import/export windows to a non-binary format such as JSON or XML, but that seems not to be the case (or is there a way?).

Is there a way to use the script console to generate and populate a new window, or to insert components into an existing window?

This would be used for inserting templates and other components, such as navigation buttons etc.

Yes, but...

I assume here that you're referring to Vision windows. The windows are indeed binary serialized, but the underlying structure is XML. But getting the deserialization done programmatically is a pain and probably not worth it.

You can get a feel for what this looks like by opening a Vision window in the designer, right-clicking its Root Container and choosing Copy, then pasting it into Notepad. I myself tried to find a way to do this from a module and decided it wasn't worth it. For more detail, you can view that thread in the Ignition forum here .

However, that's not really useful for generating and populating a new window.

To do that, you need to do some Java programming. Vision is Java Swing under the hood. There are a couple ways you can dynamically build / populate a Window.

  1. From Python, you can import any Java libraries you need and generate the window dynamically. For relatively simple things, you're probably better off working with the Template Canvas component. There's an Ignition forum thread discussing this topic here . This would be more of a run-time generation, not from the Script Console.
  2. You can write your own module to do it.

Module SDK Vision Component Guide

Vision Component Module Example

Good luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM