Does anyone know if it is possible to programmatically get the file name of a window from a script file? My application has lots of different windows. When troubleshooting with the end users, its hard to understand what window they are on. I wanted to add a tiny label to each screen with the window file name in it...that way I can troubleshoot without having to physically go to the workstation to see where the problem is.
Like in the screenshot...Can I somehow pull "Line Selection" and load that into a label dynamically?
system.gui.getWindowNames can get you a full list, but then you would need to do some parsing.
if event.propertyName == "componentRunning":
from com.inductiveautomation.factorypmi.application import FPMIWindow
from javax.swing import SwingUtilities
event.source.text = SwingUtilities.getAncestorOfClass(FPMIWindow, event.source).name
Works on pretty much any component, including a label. Note that in the designer, you must be in preview mode when the window opens for the script to actually run.
1 Like