默认显示image1,
鼠标滑动滚动条切换图片显示
可视化效果:
image_compare.py
import sys
from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QSlider, QVBoxLayout, QHBoxLayout
from PyQt5.QtCore import Qt, QSize
from PyQt5.QtGui import QPixmap, QPainter, QImageclass ImageCompareWidget(QWidget):def __init__(self, image1_path, image2_path, target_size):super().__init__()self.image1 = self.resize_image(QImage(image1_path), target_size)self.image2 = self.resize_image(QImage(image2_path), target_size)self.image_width = target_size[0]self.