def get_repr_png_image(self): # put this in in the hope that it would apply the layout resizing # before converting to PNG. It still doesn't. So in notebook, have to # use separate cells QtGui.QApplication.processEvents() # Need to keep a reference to the image, otherwise Qt segfaults image = QtGui.QImage(self.viewRect().size().toSize(), QtGui.QImage.Format_RGB32) painter = QtGui.QPainter(image) self.render(painter) return image
# -*- coding: utf-8 -*- """ Created on Mon Nov 13 09:16:38 2017 @author: sol """ import os import pyqtgraph import markwrite from pyqtgraph import QtCore, QtGui from markwrite.util import get_resource_folder_path, getIconFilePath icon_folder = os.path.join(get_resource_folder_path(), 'icons') ifiles = os.listdir(icon_folder) for i in ifiles: newi = i[1:] ipath = getIconFilePath(i) print ipath image = QtGui.QImage() image.load(ipath) image.save(getIconFilePath(newi))