mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-11 16:52:29 +03:00
Add KDE Wayland support for ImageGrab
This commit is contained in:
parent
1cb6c7c347
commit
722283e819
|
@ -40,9 +40,7 @@ class TestImageGrab:
|
||||||
|
|
||||||
@pytest.mark.skipif(Image.core.HAVE_XCB, reason="tests missing XCB")
|
@pytest.mark.skipif(Image.core.HAVE_XCB, reason="tests missing XCB")
|
||||||
def test_grab_no_xcb(self) -> None:
|
def test_grab_no_xcb(self) -> None:
|
||||||
if sys.platform not in ("win32", "darwin") and not shutil.which(
|
if sys.platform not in ("win32", "darwin") and not shutil.which("gnome-screenshot") and not shutil.which('spectacle'):
|
||||||
"gnome-screenshot"
|
|
||||||
):
|
|
||||||
with pytest.raises(OSError) as e:
|
with pytest.raises(OSError) as e:
|
||||||
ImageGrab.grab()
|
ImageGrab.grab()
|
||||||
assert str(e.value).startswith("Pillow was built without XCB support")
|
assert str(e.value).startswith("Pillow was built without XCB support")
|
||||||
|
|
|
@ -80,11 +80,16 @@ def grab(
|
||||||
if (
|
if (
|
||||||
display_name is None
|
display_name is None
|
||||||
and sys.platform not in ("darwin", "win32")
|
and sys.platform not in ("darwin", "win32")
|
||||||
and shutil.which("gnome-screenshot")
|
|
||||||
):
|
):
|
||||||
fh, filepath = tempfile.mkstemp(".png")
|
fh, filepath = tempfile.mkstemp(".png")
|
||||||
os.close(fh)
|
os.close(fh)
|
||||||
|
if shutil.which("gnome-screenshot"):
|
||||||
subprocess.call(["gnome-screenshot", "-f", filepath])
|
subprocess.call(["gnome-screenshot", "-f", filepath])
|
||||||
|
elif shutil.which("spectacle"):
|
||||||
|
subprocess.call(["spectacle", "-n", "-b", "-f", "-o", filepath])
|
||||||
|
else:
|
||||||
|
os.unlink(filepath)
|
||||||
|
raise
|
||||||
im = Image.open(filepath)
|
im = Image.open(filepath)
|
||||||
im.load()
|
im.load()
|
||||||
os.unlink(filepath)
|
os.unlink(filepath)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user