I would simply like to understand how to close the render window after it is finished and ready. The save path is already set, so it does not require manual save.
Right now I use this system to render, and it works well:
bpy.ops.render.render('INVOKE_DEFAULT',animation=False, write_still=True)
I thought adding a simple operator to close the window, I found this in the blender documents:
bpy.ops.render.view_cancel()
But obviously it gives me a context
error.
I don't understand what kind of context I have to overwrite to pass the right context, I think the rendering window has its context, but it is really difficult to get to this solution
How to use bpy.ops.render.view_cancel() to close render view?
Edit:
I am trying to reach the right context I think I have succeeded, now I no longer receive the error, but this operator does not seem to close the window, on the contrary, brings it back to the foreground:
for w in bpy.context.window_manager.windows:
for area in w.screen.areas:
if area.type == 'IMAGE_EDITOR':
for rgn in area.regions:
if rgn.type == 'WINDOW':
override = {'window': w, 'screen': w.screen, 'area': area, 'region': rgn,'workspace': w.workspace}
bpy.ops.render.view_cancel(override)