MCPcopy
hub / github.com/PyQt5/PyQt / __init__

Method __init__

QLabel/ImageSlipped.py:23–39  ·  view source on GitHub ↗
(self, bg, fg, *args, **kwargs)

Source from the content-addressed store, hash-verified

21class SlippedImgWidget(QWidget):
22
23 def __init__(self, bg, fg, *args, **kwargs):
24 super(SlippedImgWidget, self).__init__(*args, **kwargs)
25 # 开启鼠标跟踪
26 self.setMouseTracking(True)
27 # 背景
28 self.bgPixmap = QPixmap(bg)
29 # 前景
30 self.pePixmap = QPixmap(fg)
31 # 最小尺寸(背景右边和下方隐藏10个像素)
32 size = self.bgPixmap.size()
33 self.setMinimumSize(size.width() - 10, size.height() - 10)
34 self.setMaximumSize(size.width() - 10, size.height() - 10)
35 # 分成10份用于鼠标移动判断
36 self.stepX = size.width() / 10
37 self.stepY = size.height() / 10
38 # 偏移量
39 self._offsets = [-4, -4, -4, -4] # 背景(-4,-4),前景(-4,-4)
40
41 def mouseMoveEvent(self, event):
42 super(SlippedImgWidget, self).mouseMoveEvent(event)

Callers

nothing calls this directly

Calls 2

widthMethod · 0.45
heightMethod · 0.45

Tested by

no test coverage detected