it works like this :
---------------------
import maya.OpenMaya as om
om.MGlobal.displayError("Nothing Selected")
om.MGlobal.displayWarning("This is a warning")
import sys
sys.__stdout__.write('hello world\n')
--
-deane
Do you mean when you run
print("something")
in Python in script editor in maya, it does not print the result in the script editor but only in command line output?
Could you explain in more detail what you are doing.
Yury
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/b4c245a5-e2ba-41f3-86c6-20a2b41b0154%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I actually figured it out. Lol :P
Since I was overwriting XStream and redefining stdout I needed to reset stdout to point to Maya's output, but where is that? Well, the hint was staring me in the face, I just needed to find it; the answer was in plogging.py (pymel's logging system). There's a function called _fixMayaOutput and they use it to reset their own logging system. I used similar logic to flush my own system back to Maya's.
So...
import sys
from maya import utils
# redefine sys.stdout
sys.stdout = utils.Output
# in order to use stdout 'write' requires a 'maya.Output' so we flush it
class MayaOutput(sys.stdout):
def flush(*args, **kwargs):
utils.Output = MayaOutput()
sys.stdout = utils.Output
# initialize
log = MayaOutput()
# and flush, we're back to feeding output to the script editor
log.flush()
print("Hello World")
You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/FOJtmJjGDwc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CACqGSch_NPQKwDbcKi%2BKAB%3DmLZxSfDuKV32aVx60fE-%2BXsXptg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAMh9y_CpatAAYzJ9h5Ajmnih%2BjS1qdjfE8Hgkfbt2LRyaKrCxQ%40mail.gmail.com.