I’m using Ignition 7.9.8 and would like to use the python ‘importlib’ module and importing it in a button pressed event scripting area causes an error saying 'no module named import lib.
I need this to import and call functions out of a script external to the ignition system.
Basically, the following line: import importlib.util
does not work.
tkinter is the standard python interface for tcl-tk. Tcl is a C library, which means it’s effectively off-limits for usage in Ignition/Jython. There is a Java implementation of tcl, but you probably don’t want to go down that road.
In Ignition you’re much better off sticking with java.awt or javax.swing for display purposes. The easiest way to say, open a message box, is by using Ignition’s built-in system.gui.messageBox() function.
You are writing about two different modules here. importlib.util is a Python 3 system module that is not available in Ignitions Phyton 2.5.
If your module references importlib you need to remove that reference.
The knowledge base article you linked is clear about both cases:
The library or module is not written in C and is not dependent on C / C-Python features
The library is Python 2.5 compatible (*as of Ignition 7.8, Ignition uses Jython 2.5)
Ignition’s scripting facilities are top-tier as far as convenience and extensibility are concerned. The default GUI toolkit you get with Jython just happens to be swing, not tcl.tk. I believe you could, in theory, package up Jacl in an Ignition module, import it, and create tk GUIs in Jython.
Or you can code up screens using swing in Jython.
Or you can use the Vision Designer to graphically create windows and then call them through scripting.
I have asked this elsewhere, but am going to ask here also, since you guys seem to be responding and knowledgeable.
IN working with an Easy Chart component, I would like to interrogate the Chart in python and retrieve a list of tags (with their paths) that the chart is using. I have some extra data I would like to value-add to the chart.