def _configure(self, qtile, bar):
        base._Widget._configure(self, qtile, bar)

        if not self.filename:
            raise ValueError("Filename not set!")

        self.filename = os.path.expanduser(self.filename)

        try:
            self.image = cairocffi.ImageSurface.create_from_png(self.filename)
        except MemoryError:
            raise ValueError("The image '%s' doesn't seem to be a valid PNG"
                % (self.filename))

        self.pattern = cairocffi.SurfacePattern(self.image)

        self.image_width = self.image.get_width()
        self.image_height = self.image.get_height()

        if self.scale:
            if self.bar.horizontal:
                new_height = self.bar.height - (self.margin_y * 2)

                if new_height and self.image_height != new_height:
                    scaler = cairocffi.Matrix()
                    sp = self.image_height / new_height
                    self.image_height = new_height
                    self.image_width = int(self.image_width / sp)
                    scaler.scale(sp, sp)
                    self.pattern.set_matrix(scaler)
            else:
                new_width = self.bar.width - (self.margin_x * 2)

                if new_width and self.image_width != new_width:
                    scaler = cairocffi.Matrix()
                    sp = self.image_width / new_width
                    self.image_width = new_width
                    self.image_height = int(self.image_height / sp)
                    scaler.scale(sp, sp)
                    self.pattern.set_matrix(scaler)
dataset/ETHPy150Open qtile/qtile/libqtile/widget/image.py/Image._configure/original