def set_background(self, path=None): '''Set character snapshot picture ''' if not (path and os.path.exists(path)): path = self._get_default_snapshot() self.background = None else: self.background = path # Load image image = QtGui.QImage(path) self.setPixmap(QtGui.QPixmap.fromImage(image))
def get_icon(icon, size=24): """get svg icon from icon resources folder as a pixel map """ img = get_icon_path("{}.svg".format(icon)) svg_renderer = QtSvg.QSvgRenderer(img) image = QtGui.QImage(size, size, QtGui.QImage.Format_ARGB32) # Set the ARGB to 0 to prevent rendering artifacts image.fill(0x00000000) svg_renderer.render(QtGui.QPainter(image)) pixmap = QtGui.QPixmap.fromImage(image) return pixmap