# get project instance
p = QgsProject.instance()
# get layout manager
m = p.layoutManager()
# get layout from manager
layout = m.layouts()[0]
# get layout items
items = layout.items()
# iterate through layout items and find map
for item in items:
if isinstance(item, QgsLayoutItemMap):
break
mapItem = item
# change the background colour by passing an RGB QColor object
mapItem.setBackgroundColor(QColor(60,255,240))
# refresh the layout to apply change
layout.refresh()
Matt
- 17.9k
- 4
- 23
- 59