Hello everyone, i wolud like to know if there is a way to find a component property in a different windows and the component is also in a group.
Yes, but only in a script, not in a binding. First, you would use system.gui.getWindow to obtain the window object (it must be open), then use its .getComponentForPath() method to drill into the component hierarchy to the target component. You can then access its properties as jython attributes. (Using their scripting names--shown when hovering in the property panel.)
Thank you for your reply. What I want to do is change the visible property of a rectangle. The rectangle is in a dock window, so my idea is to change the visibility of the rectangle when a certain window is open. I'm placing the code in a VisionWindowOpened
event, and this is the window that will change the visibility of my rectangle. However, when I open the window in the client, a system warning appears, showing a script error related to VisionWindowOpened
.
this is the code:
window = system.gui.getWindow('Docked Windows/Electrical Trend Menu')
group = window.rootContainer.getComponent("Group 36")
group.getComponent("Rectangle 1").visible = False
I tested the code in script console and it seems is working good, i do not know why in the VisionWindowOpened is not working as well
Show the error. Be sure to obtain the full details, via the clipboard, and paste the entire traceback here using "preformatted" styling.
{ Be aware that VisionWindowOpened is an event that runs very early in a window's lifecycle, before everything is initialized, so breakage is common. }
Now that we know this, I would say that direct scripting is probably not the correct approach. Scripting with getWindow
will only work if the window is already opened, and if the window is in another desktop, it gets more complicated.
A simpler approach would be to use a client tag. Bind the visibility property of your rectangle to the tag value, and write True
to the tag using the Vision window opened event, and conversely write False
to the tag on close.