Hello I’m trying to get the error messages from the dialog boxes through script to handle certain errors, but I can’t seem to find where the messages can be grabbed from
I’m using the code below to close open dialog boxes within the client, but I want to save the message somewhere. I’m trying to close them because they shouldn’t show up in client. The error and warning messages show up in output console, but I’m not sure how to reach that through script either
Example in output console
16:40:50.399 [AWT-EventQueue-0] ERROR com.inductiveautomation.factorypmi.application.script.builtin.WindowUtilities - Something
16:40:50.420 [AWT-EventQueue-0] WARN com.inductiveautomation.factorypmi.application.script.builtin.WindowUtilities - Something 21
"""
Description:
The warning box in Ignition can be minimized and therefore not seen again.
To fix this, we will add a window listener that will intercept the minimize action
and remaximize that said window
"""
from javax.swing import SwingUtilities
from java.awt.event import WindowAdapter
from javax.swing import JFrame
from com.inductiveautomation.factorypmi.application.script.builtin import WindowUtilities
class dialogBoxListener(WindowAdapter):
def windowIconified(self,event):
event.source.setState(JFrame.NORMAL)
#Create an instance of the warning box
#system.gui.warningBox("warning","Warning")
#system.gui.errorBox("Something", "Error")
#system.gui.errorBox("Something", "Error")
#Find the warning box
par = event.source
par = SwingUtilities.getRoot(par)
warnWindow = errWindow = None
system.gui.errorBox("Something")
system.gui.warningBox("Something 21")
#Grabing all the warning and error windows
try:
getwindows = [w for w in par.getWindows()]
warnWindow = [w for w in getwindows if "title=Warning" in str(w)][0]
errWindow = [w for w in getwindows if "title=Error" in str(w)][0]
except:
pass
#If there are warning windows, close them
if warnWindow!=None:
print(warnWindow)
warnWindow.addWindowListener(dialogBoxListener())
warnWindow.center()
warnWindow.close()
#If there are error windows, close them
if errWindow!=None:
print(errWindow)
errWindow.addWindowListener(dialogBoxListener())
errWindow.center()
errWindow.close()
Thank you!!