This seems like it should be simple, but I've searched and can't find the answer. I am running a Python macro that interacts with another proprietary IDE. I can build and capture the error output. Is there a way to send this output to the "Command Output" tab and have it parsed the way you can with a simple "Run" item in the toolbox?
I am new to Python, but I'm using it because it allowed access to the ActiveX control used to script the proprietary IDE.
Regards,
Dave
It is not easy for Python macros to access to the actual UI elements, but here is some code that should get you there:
wm = components.classes["@mozilla.org/appshell/window-mediator;1"].getService(components.interfaces.nsIWindowMediator)
win = wm.getMostRecentWindow("Komodo")
# Get the run output element in the UI.
elem = win.document.getElementById('runoutput-scintilla')
elem.QueryInterface(components.interfaces.koIScintillaView)
scimoz = elem.scimoz
scimoz.readOnly = False
scimoz.text = "Hello\nthere\n"
from xpcom import components wm = components.classes["@mozilla.org/appshell/window-mediator;1"].getService(components.interfaces.nsIWindowMediator) win = wm.getMostRecentWindow("Komodo") # Get the run output element in the UI. elem = win.document.getElementById('runoutput-scintilla') elem.QueryInterface(components.interfaces.koIScintillaView) scimoz = elem.scimoz scimoz.readOnly = False scimoz.text = "Hello\nthere\n"Cheers,
Todd
Todd,
Thanks for the code. I had to change it slightly to make it run without errors. I added an import line, and changed the case. Unfortunately, the text is not being displayed.
Here's the code:
wm = components.classes["@mozilla.org/appshell/window-mediator;1"].getService(components.interfaces.nsIWindowMediator)
win = wm.getMostRecentWindow("Komodo")
# Get the run output element in the UI.
elem = win.document.getElementById('runoutput-scintilla')
elem.QueryInterface(components.interfaces.koIScintillaView)
scimoz = elem.scimoz
scimoz.text="Hello\nthere\n"
from xpcom import components wm = components.classes["@mozilla.org/appshell/window-mediator;1"].getService(components.interfaces.nsIWindowMediator) win = wm.getMostRecentWindow("Komodo") # Get the run output element in the UI. elem = win.document.getElementById('runoutput-scintilla') elem.QueryInterface(components.interfaces.koIScintillaView) scimoz = elem.scimoz scimoz.text="Hello\nthere\n"Komodo Version: 5.1.4, build 3797
WinXP Pro
I still can't get this to work. Any other ideas?
Regards
The above code should work - note you'll need the "from xpcom import components" line as noted by Dave.
If it's not working for you, you might want to install the Komodo Developer Extension:
http://community.activestate.com/xpi/komodo-developer-extension
then use the "Tools->Extension Developer->PyShell" to launch an interactive Python window, paste in line by line and see where it's failing...
Cheers,
Todd
Actually Todd's code works. I made it append to existing text instead of overwriting it:
def log(line):
wm = components.classes["@mozilla.org/appshell/window-mediator;1"].getService(components.interfaces.nsIWindowMediator)
win = wm.getMostRecentWindow("Komodo")
# Get the run output element in the UI.
elem = win.document.getElementById('runoutput-scintilla')
elem.QueryInterface(components.interfaces.koIScintillaView)
scimoz = elem.scimoz
scimoz.text += line + '\n'
log('hello there?')
from xpcom import components def log(line): wm = components.classes["@mozilla.org/appshell/window-mediator;1"].getService(components.interfaces.nsIWindowMediator) win = wm.getMostRecentWindow("Komodo") # Get the run output element in the UI. elem = win.document.getElementById('runoutput-scintilla') elem.QueryInterface(components.interfaces.koIScintillaView) scimoz = elem.scimoz scimoz.text += line + '\n' log('hello there?')I loaded the developer extension and ran the macro line by line in pyshell. When I type the line:
elem.QueryInterface(components.interfaces.koIScintillaView)
I get the following error message:
XPCOM component '' (implementing koIScintillaView, nsIDOM3Node, nsIDOMElement, nsIDOMElementCSSInlineStyle, nsIDOMEventTarget, nsIDOMNSElement, nsIDOMXULElement)
I can continue and append text to the scimoz text property. If I do a "print(scimoz.text)" the text is echoed to the python console, but the text does not appear in the Command tab.
Any ideas?
SciMoz may be in a read-only state, so try adding this before the set text call:
That did the trick! Thanks. I had tried this awhile back, but I think there was another error and I took the line out.