def setup_images(self):
        """Create image structures for each icon files."""
        self._icon_size = self.icon_size if self.icon_size is not None else self.bar.height - 4
        self._icon_padding = (self.bar.height - self._icon_size) // 2

        for img_name, iconfile in self.icons_files.items():
            if iconfile is None or self.text_only:
                # Only warn the user that there's no icon if they haven't set text only mode
                if not self.text_only:
                    logger.warning(
                        'No icon found for application "%s" (%s) switch to text mode',
                        img_name,
                        iconfile,
                    )
                # if no icon is found and no default icon was set, we just
                # print the name, based on a textbox.
                textbox = base._TextBox()
                textbox._configure(self.qtile, self.bar)
                textbox.layout = self.drawer.textlayout(
                    textbox.text,
                    self.foreground,
                    self.font,
                    self.fontsize,
                    self.fontshadow,
                    markup=textbox.markup,
                )
                # the name will be displayed
                textbox.text = img_name
                textbox.calculate_length()
                self.icons_widths[img_name] = textbox.width
                self.surfaces[img_name] = textbox
                continue
            else:
                try:
                    img = Img.from_path(iconfile)
                except cairocffi.Error:
                    logger.exception(
                        'Error loading icon for application "%s" (%s)', img_name, iconfile
                    )
                    return

            input_width = img.width
            input_height = img.height

            sp = input_height / (self._icon_size)
            width = int(input_width / sp)

            imgpat = cairocffi.SurfacePattern(img.surface)
            scaler = cairocffi.Matrix()
            scaler.scale(sp, sp)
            scaler.translate(self.padding * -1, -2)
            imgpat.set_matrix(scaler)

            imgpat.set_filter(cairocffi.FILTER_BEST)
            self.surfaces[img_name] = imgpat
            self.icons_widths[img_name] = width
Create image structures for each icon files.
libqtile/widget/launchbar.py