```py from PySide6.QtCore import * from PySide6.QtGui import * from PySide6.QtWidgets import * from glob import glob import os import sys app = QApplication([]) i = 0 pngs = [] while os.path.exists(fn:=f"{i}.png"): pngs.append(fn) i += 1 pixmaps = [ QPixmap(png) for png in pngs ] idx = 0 # How to draw regions of a pixmap class Canvas(QWidget): def __init__(self,*xs,**kw): super().__init__(*xs,**kw) self.resize(800,600) def paintEvent(self,e): pixmap = pixmaps[0] rect = self.rect() srect = QRect(200,200,1200,500) trect = QRect(10,10,400,300) with QPainter(self) as qp: qp.fillRect(rect,Qt.red) qp.drawPixmap(trect,pixmap,srect) canvas = Canvas() canvas.show() exit(app.exec()) ```