Dashboard_avatar
Feb 23, 2010
Post id: 301874 Report Item

Hi. I develop my ScriptEditor implementation.I use python, PyQt4, qscintilla.It work well for me.But:I need normal Output( echo ) update. When I enter commands in this ScriptEditor it updates normal  after commands executes. But when user use commands from without( not in this editor ) it need to aumatic update output. So, I use 'RecentCommandChanged' event(scriptJob) to automatic update.It work normal ( for succes results commands ). But when it is invalid, for example user choose PolyBevel for nurbs - generates error, but output dont know about it.In ideal i need something near connection between CommandWindow output or cmdScrollFieldReporter with my output field. In API a dont find any function for report contents. Any ideas...
sory for bad english...

Dashboard_avatar
Feb 24, 2010
Post id: 301885 Report Item

Mayas not event based not in this sense, maya has encapsulated theese in form that makes sense to maya but not so much qt, half of the time if you think in terms of evvents you get shafted. You just need to think things differently thats all.


 


Second python pushes errors to the output window not script editor. If you want them shown in niormal script editor you need to catch them and print yourself. THis makes sense especially when you have a separate therad running in wich case you need to defeer the printing to main thread.


 


Dont use scriptjobs for this.

Dashboard_avatar
Feb 24, 2010
Post id: 301888 Report Item

u meant, write to Maya editor by using "utils.executeInMainThreadWithResult(...)" ? But HOW?


utils.executeInMainThreadWithResult( "import sys; sys.stdout.write('blah blah..')" ) doesnt work.

Dashboard_avatar
Feb 24, 2010
Post id: 301896 Report Item

What part of your code redirected the stdout? I mean qt probably did, atleast it used to anyway i dont have qt installed so i cant test. but this works fairly well in both tk an wxpython.


you can redirect sys.stdout to whatever you want with the


sys.stdout = maya.utils.Output()


you redirect it to maya script editor


sys.stderr = maya.utils.Output( error=1 )


redirects errors back to maya script editor


Offcourse if you wish them to go to the output window, or console in you can go and do:


sys.stdout = sys.__stdout__


sys.stderr = sys.__stderr__


or any file object really.


after this you can just use print wich is basically the same as sys.stdout.write()


I think that redirection itself is enough you dont really necceserily need to use utils.executeInMainThreadWithResult as long as the handle works. Didnt test tough.