docs: def capture_widget(widget, path=None):
      """Grab an image of a Qt widget
  
      Args:
          widget: The Qt Widget to capture
          path (optional): The path to save to. If not provided - will return image data.
  
      Returns:
          If a path is provided, the image will be saved to it.
          If not, the PNG buffer will be returned.
      """
      if use_qt5:
          pixmap = widget.grab()
      else:
          pixmap = QtGui.QPixmap.grabWidget(widget)
  
      if path:
          pixmap.save(path)
  
      else:
          image_buffer = QtCore.QBuffer()
          image_buffer.open(QtCore.QIODevice.ReadWrite)
  
          pixmap.save(image_buffer, "PNG")
  
          return image_buffer.data().data()