Hi guys, I have a couple of question about the Alarm Status Table in Vision.
I have a touchscreen where I show the main alarms of the plants.. The questions are:
How can I change the size of the vertical scrollbar (with the touch is quite difficult to move it)
I set the Alarm Table in marquee mode but I would like to disable it when I have new alarms active; this is not a problem, I can manage it, but I don't know how I can return to the top, because as soon as I disable the marquee mode it freezes in the row without moving the view to the top.
I was able to accomplish this from a button on my alarm status table using the following code:
from java.awt import Dimension
scrollPane = event.source.parent.getComponent('Alarm Status Table').getComponent(0).getComponent(0).getComponent(1).getComponent(0)
scrollPane.getVerticalScrollBar().setPreferredSize(Dimension(100, 0))
The code gets the scroll pane and directly sets the preferred width of the vertical scroll bar. Here is the result:
This button actionPerformed script works on my alarm status table:
from java.awt import Point
viewPort = event.source.parent.getComponent('Alarm Status Table').getComponent(0).getComponent(0).getComponent(1).getComponent(0).getComponent(0)
viewPort.setViewPosition(Point(0,0))
It gets the viewport and sets the position to zero.
Most components are actually a groups of nested components. If you take a component and use the method getComponents(), a list of subcomponents will be returned. To get a specific subcomponent in the list an index can be specified: either .getComponents()[index] or simply getComponent(index)
To find a type of component in this way, it is possible to drill down level by level using something like:
for subComponent in component.getComponents():
print type(subComponent)
Extending this, here's what I used to use in Vision to see what all the components in IA components are:
# traverse all components within an object and print them and their component index reference to the screen
def printAllObjectComponents(object, indexPrefix = '', indent = ''):
components = object.getComponents()
for index, component in enumerate(components):
print "%s %s%s %s" % (indent, indexPrefix, index, component)
printAllObjectComponents(component, indexPrefix + str(index) + '.', indent + '\t')