code: def screenshot(filename="screenshot.png"):
      
      if not settings.plotter_instance.window:
          colors.printc('~bomb screenshot(): Rendering window is not present, skip.', c=1)
          return
      w2if = vtk.vtkWindowToImageFilter()
      w2if.ShouldRerenderOff()
      w2if.SetInput(settings.plotter_instance.window)
      w2if.ReadFrontBufferOff()  # read from the back buffer
      w2if.Update()
      pngwriter = vtk.vtkPNGWriter()
      pngwriter.SetFileName(filename)
      pngwriter.SetInputConnection(w2if.GetOutputPort())
      pngwriter.Write()
docs: Save a screenshot of the current rendering window.