Пример #1
0
def test_image():
    img = gui.Image()
    with open("data.pkl", "wb") as jar:
        pickle.dump(img, jar)
    with open("data.pkl", "rb") as jar:
        img = pickle.load(jar)
    bytes(img)
Пример #2
0
 def get_image(self, mode: ModeStr = "clipboard") -> gui.Image | None:
     if mode not in MODES:
         raise InvalidParamError(mode, MODES)
     img = gui.Image(self.item.image(MODES[mode]))
     if img.isNull():
         return None
     return img
Пример #3
0
 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
Пример #4
0
def test_painter():
    painter = gui.Painter(gui.Image())
    painter.use_antialiasing()
    painter.set_pen("none")
    painter.fill_rect((0, 1, 3, 5), "transparent")
    painter.fill_rect(core.Rect(), "transparent")
    with pytest.raises(ValueError):
        painter.fill_rect(core.Rect(), "testus")
    painter.set_color("black")
    painter.set_composition_mode("source_atop")
    with pytest.raises(ValueError):
        painter.set_composition_mode("test")
    with pytest.raises(ValueError):
        painter.set_pen("test")
Пример #5
0
def test_quickwindow():
    window = quick.QuickWindow()
    window.create_texture_from_image(gui.Image())
    window.grab_window()
    window.get_color()
    window.set_text_render_type("native_text")
    with pytest.raises(InvalidParamError):
        window.set_text_render_type("test")
    assert window.get_text_render_type() == "native_text"
    with window.external_commands():
        pass
    runnable = core.Runnable()
    with pytest.raises(InvalidParamError):
        window.schedule_render_job(runnable, "test")
    window.schedule_render_job(runnable, "before_rendering")
Пример #6
0
 def get_image(self) -> gui.Image:
     return gui.Image(self.image())
Пример #7
0
 def to_image(self) -> gui.Image:
     return gui.Image(self.toImage())
Пример #8
0
 def read_image(self) -> gui.Image:
     return gui.Image(self.read())
Пример #9
0
 def grab_window(self) -> gui.Image:
     return gui.Image(self.grabWindow())