Geographic Information Systems Asked on November 1, 2021
I would like to run a QgsTask when I push a button in a Qgis plugin (3.10).
My task is a subclass similar to this example
In the main class of my plugin, I have added this (connected to the button that works) :
def myBtnAction(self) :
from .my_task import MyTask
task = MyTask('run my task', 20)
QgsApplication.taskManager().addTask(task)
The task is never executed.
Did you try the standalone version running in PyQGIS Python console like below (clearly borrowed from your link and reindented)?
class MyTask(QgsTask):
def __init__(self, description, flags):
super().__init__(description, flags)
def run(self):
QgsMessageLog.logMessage('Started task {}'.format(self.description()))
#print('crashandburn')
return True
t1 = MyTask('waste cpu', QgsTask.CanCancel)
QgsApplication.taskManager().addTask(t1)
In my case, it "works". So what does MyTask
from your from .my_task import MyTask
looks like? Did you try to use your task code outside the plugin to find where the issue could be?
Answered by ThomasG77 on November 1, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP