def test_painterpath(): path = gui.PainterPath() rect = core.RectF(0, 0, 1, 1) path.addRect(rect) assert len(path) == 5 assert bool(path) assert core.PointF(0.5, 0.5) in path path[1] = (0.5, 0.5) path.add_rect(QtCore.QRect(0, 0, 1, 1))
def pixmap(self, size: QtCore.QSize, mode: QtGui.QIcon.Mode, state: QtGui.QIcon.State) -> QtGui.QPixmap: """Return the icon as a pixmap with requested size, mode, and state.""" img = gui.Image(size, QtGui.QImage.Format.Format_ARGB32) img.fill(QtCore.Qt.GlobalColor.transparent) pixmap = QtGui.QPixmap.fromImage( img, QtCore.Qt.ImageConversionFlag.NoFormatConversion) rect = QtCore.QRect(QtCore.QPoint(0, 0), size) self.paint(QtGui.QPainter(pixmap), rect, mode, state) return pixmap
def set_mask( self, area: types.RectType | QtGui.QRegion | None, typ: gui.region.RegionTypeStr = "rectangle", ): if area is None: self.clearMask() return if isinstance(area, tuple): area = QtCore.QRect(*area) if isinstance(area, QtCore.QRect): area = gui.Region(area, gui.region.REGION_TYPE[typ]) self.setMask(area)
def heightForWidth(self, width: int) -> int: rect = QtCore.QRect(0, 0, width, 0) return self.do_layout(rect, True)