Using python help function

I am trying to dig into the hidden component features using python scripting. I can see all the available function in the component when I use “print dir(component)” however once I find the function I want to use I do not always know what parameters it takes. Is there a way to use the built in help function in python to have it display the parameters for the function?

When I try to just use help (component.functionName()) it gives me the error
[color=#FF0000]Traceback (most recent call last):
File “event:mouseClicked”, line 1, in
NameError: name ‘help’ is not defined
[/color]

Is this function not supported?

According to Python documentation you have to import the site module.

Example:

import site
print help([])

Best,

Thanks Nick,

We are getting closer. Now if I run the code

import site print help(event.source.getChart().getPlot())

I get this for the output in the console.

[quote]Help on PiePlot object:

<type 'org.jfree.chart.plot.PiePlot'>
None
[/quote]

So if I look in the functions available inside event.source.getChart().getPlot() using the dir function

print dir(event.source.getChart().getPlot())

I can see that there is a function that is called setOutlinePaint() which is self explanatory, it sets the color of the outline paint which can be used to get rid of the unnecessary boarder that comes with the component. It took me awhile to find what this function took as a parameter(which is just a color in either HEX or RGB). So if I plug the following into the help function

import site print help(event.source.getChart().getPlot().setOutlinePaint())

I get an error saying

I would like to be able to find the function with the dir function and then plug that function into the help function to see what parameters it takes and how the function works. Any thoughts on that?

Hi,

You got that error because you called the function without passing in the argument that it expects. It will work if you pass in the function without calling it. Example:

import site
print help(event.source.getChart().getPlot().setOutlinePaint)

But really the “help” function isn’t going to help you because it is only useful on native Python objects, such as Python lists and dictionaries and other Python stuff. The components in Ignition are written in Java, not Python, so “help” is not going to help.

You can use “dir” to find methods on objects. To learn more, like information about method parameters, you will need to use the Java Reflection API.

Sometimes an easier way is to find and read the underlying documentation for the technologies that Ignition is using. For example the charts in Ignition use JFreeChart. Or read Swing documentation. Many components in Ignition are built from Swing components.

Best,