Sunday, 29 November 2015

(pyqgis) Is there a way to disable the progress bar in the processing tool


When using processing tool in pyqgis and run, it always creates a progress bar. Is there a way to disable it?


processing.runalg('qgis:fixeddistancebuffer', _layer, distance_tolerance, 10, False, None)

I want to disable it because I get this error when I run my script in travis:




wrapped C/C++ object of type QProgressBar has been deleted See log for more details


RuntimeError: wrapped C/C++ object of type QProgressBar has been deleted




Answer



This works for me:


processing.runalg('qgis:fixeddistancebuffer', _layer, distance_tolerance, 10, False, None, progress=None)

Just add "progress = None" and you may be good to go


Update: I figured out that you can actually keep track of the process's progress using some kind of dummy progress object. Here's what I have:



class DummyProgress(object):
def __init__(self):
pass

def error(self, er_msg):
print er_msg

def setPercentage(self, percent):
print str(percent)


def setText(self, text):
print text

def setCommand(self, comd):
print comd

Instantiate an object from this class and pass it as argument to progress in your runalg and you will have everything that is happening printed to your console


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...