[PyKDE] QProcess: more guidance needed
Tina Isaksen
tina at bestemselv.com
Mon Mar 6 07:58:12 GMT 2006
Hi,
I need some QProcess pointers again I'm afraid.
I need to know when the process awaits input on it's stdin. I've been
experimenting with QProcess::Communication flags but I can't make sense
of it's output. I've also looked for some sort of SIGNAL (which would be
ideal) but no luck there either. A code snippet:
def doUpgrade(self):
# Prepare widgets #
self.mainTextWindow.setEnabled(1)
self.mainTextWindow.setReadOnly(0)
self.upgradeMessage.setEnabled(1)
self.upgradeMessage.setReadOnly(0)
self.mainTextWindow.clear()
self.pbSaveMain.setEnabled(0)
self.upgradeMessage.setText("Upgrading packages, please wait...")
self.upgradeProcess = QProcess()
self.connect(self.upgradeProcess, SIGNAL("readyReadStdout()"),
self.readOutput)
self.connect(self.upgradeProcess, SIGNAL("processExited()"),
self.upgradeProcessExit)
self.connect(self.upgradeProcess, SIGNAL("readyReadStderr()"),
self.readUpgradeErrors)
self.upgradeProcess.setArguments((QStringList.split(" ",
"apt-get upgrade")))
self.upgradeProcess.start()
###
### Need to know if upgradeProcess awaits input ###
###
def readOutput(self):
self.mainTextWindow.append(QString(self.upgradeProcess.readStdout()))
def upgradeProcessExit(self):
self.mainTextWindow.append("Done!")
# Return widgets to defaults (foolproofing) #
self.upgradeMessage.setText(" ")
self.upgradeMessage.setEnabled(0)
self.pbSaveMain.setEnabled(0)
self.mainTextWindow.setReadOnly(1)
def readUpgradeErrors(self):
self.mainTextWindow.append(QString(self.upgradeProcess.readStderr()))
For the entire code, see
http://svn.berlios.de/wsvn/tinapt/trunk/tinaptMainProg.py?op=file&rev=0&sc=0
Thanks
Tina
--
Project: Tinapt
http://tinapt.berlios.de/
SVN repository:
http://svn.berlios.de/wsvn/tinapt/trunk/?rev=0&sc=0
More information about the PyQt
mailing list