I have a console script where I'm trying to iterate through saved bookmarks from the open project to have the map pan/zoom to the bookmark extent. I would like to eventually save each map canvas as pdf file. I can manually set the right parameters to cycle through the bookmarks and the canvas refreshes each time I set the extent.
However, if I cycle through the saved bookmarks and set the canvas extent in a for loop (as below), the canvas does not refresh with each extent change, it only refreshes once the script has run it's course. I've added sleep
commands in the for
loop to allow for redraw time, but that didn't work. Am I missing something simple?
bmarks = QgsApplication.bookmarkManager()
bmarks.bookmarks()
for b in bmarks.bookmarks():
canv = iface.mapCanvas()
canv.setExtent(b.extent())
iface.mapCanvas().refresh()