from PyQt4 import QtCoreclass processTest(QtCore.QObject): def __init__(self): super(processTest, self).__init__() process = QtCore.QProcess(parent=self) process.setProcessChannelMode(process.ForwardedChannels) process.start('python', ['-c', 'print("finished qprocess")'])myTest = processTest()from PyQt4 import QtCoreclass ProcessTest(QtCore.QObject):def __init__(self):super(ProcessTest, self).__init__()self.process = QtCore.QProcess(parent=self)self.process.setProcessChannelMode(process.MergedChannels)self.process.readyReadStandardOutput.connect(self.handle_output)def run(self):self.process.start('python', ['-c', 'print("finished qprocess")'])def handle_output(self):sys.stdout.write(self.process.readAllStandardOutput())myTest = ProcessTest()myTest.run()
--
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/94e71427-c5d8-4c18-8c85-d17cb99a74a2%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
I SO tried to get this working a year ago ("to no avail, that's why I'm telling you this sorry tale" :-).
Thanks Justin!
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1CQMCyL%3DsSiZAAy2_v67-y9fyfMAPAD%2B7g962w5BZSBw%40mail.gmail.com.
import subprocess
import sip
import maya.OpenMayaUI as mui
from PyQt4 import QtCore, QtGui
def getMainWindow():
pointer = mui.MQtUtil.mainWindow()
return sip.wrapinstance(long(pointer), QtCore.QObject)
class BlockingTestWin(QtGui.QMainWindow):
def __init__(self, parent=None):
super(BlockingTestWin, self).__init__(parent)
self.mainWidget = QtGui.QWidget()
self.setCentralWidget(self.mainWidget)
#Main layout
self.layout = QtGui.QVBoxLayout()
self.mainWidget.setLayout(self.layout)
self.blocking_button = QtGui.QPushButton("Block")
self.blocking_button.clicked.connect(self.blocking)
self.layout.addWidget(self.blocking_button)
self.signal_button = QtGui.QPushButton("Signals")
self.signal_button.clicked.connect(self.non_blocking)
self.layout.addWidget(self.signal_button)
self.output = QtGui.QLineEdit()
self.layout.addWidget(self.output)
self.clear_button = QtGui.QPushButton("Clear")
self.clear_button.clicked.connect(self.output.clear)
self.layout.addWidget(self.clear_button)
def finished(self, returnCode):
self.setMessage("Return code: %s" % returnCode)
def setMessage(self, msg):
print msg
self.output.setText(msg)
def blocking(self):
self.setMessage("Starting blocking sleep")
process = subprocess.Popen(['python', '-c', 'import time\ntime.sleep(5)'])
ret = process.wait()
self.finished(ret)
def non_blocking(self):
self.setMessage("Starting non blocking sleep")
process = QtCore.QProcess(parent=self)
process.setProcessChannelMode(process.ForwardedChannels)
process.finished.connect(self.finished)
process.start('python', ['-c', 'import time\ntime.sleep(5)'])
def run():
app = BlockingTestWin(getMainWindow())
app.show()--
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/3fbd4c03-409f-4594-bb57-8ab9509d93dc%40googlegroups.com.