[QGIS-Developer] Run python script whit QProcess and show into textEdit the result in realtime
Enzo Cocca
enzo.ccc at gmail.com
Sun Sep 26 03:28:38 PDT 2021
I wolud print the result during my script run via Qprocess but nothing
happen. I thinking I wrote wrong the args into process start but im not
sure. Some one has an idea? Below my code
class TotalopenstationDialog(QtWidgets.QDialog, FORM_CLASS):
def __init__(self, parent=None):
"""Constructor."""
super(TotalopenstationDialog, self).__init__(parent)
self.setupUi(self)
def dataReady(self):
cursor = self.textEdit.textCursor()
cursor.movePosition(cursor.End)
cursor.insertText(str(self.process.readAll()))
self.textEdit.ensureCursorVisible()
def callProgram(self):
# run the process
# `start` takes the exec and a list of arguments
python_path = sys.exec_prefix
python_version = sys.version[:3]
p = '{}\python'.format(python_path)
b=QgsApplication.qgisSettingsDirPath().replace("/","\\")#this
one works for windows path
cmd = os.path.join(os.sep, b, 'python', 'plugins',
'totalopenstationToQgis',
'scripts', 'totalopenstation-cli-parser.py')
self.process = QProcess(self)
# QProcess emits `readyRead` when there is data to be read
self.process.readyRead.connect(self.dataReady)
self.process.start(p, [cmd,
'-i',str(self.lineEdit_input.text()),'-o',str(self.lineEdit_output.text()),'-f',self.comboBox_format.currentText(),'-t',self.comboBox_format2.currentText(),'--overwrite'])
def on_pushButton_connect_pressed(self):
self.callProgram()
--
Enzo Cocca PhD
in "Science and Technology for Archaeology and Cultural Heritage"
ISMEO
International Association of Mediterranean and Oriental Studies
mail: enzo.ccc at gmail.com
cell: +393495087014
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20210926/ad5f3ba2/attachment.html>
More information about the QGIS-Developer
mailing list