I want to add a layer in QGIS that is editable and has Add Polygon Feature selected (by default). I can easily accomplish the editable part by this command:
layer = QgsVectorLayer("Polygon?crs=epsg:4326", "temporary_points", "memory")
layer.startEditing()
#Something more here?
QgsProject.instance().addMapLayer(layer)
A bonus question is why it takes extremely long time to get the saving popup when I have that as a part of my code? (and none when I run it from the Python Console)
self.layer = QgsVectorLayer(...)
in that part of the code. The solution was to make no changes in that part but just add aself.layer = None
in the init function.