mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-11 00:32:27 +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")
|
||||
def test_grab_no_xcb(self) -> None:
|
||||
if sys.platform not in ("win32", "darwin") and not shutil.which(
|
||||
"gnome-screenshot"
|
||||
):
|
||||
if sys.platform not in ("win32", "darwin") and not shutil.which("gnome-screenshot") and not shutil.which('spectacle'):
|
||||
with pytest.raises(OSError) as e:
|
||||
ImageGrab.grab()
|
||||
assert str(e.value).startswith("Pillow was built without XCB support")
|
||||
|
|
|
@ -80,11 +80,16 @@ def grab(
|
|||
if (
|
||||
display_name is None
|
||||
and sys.platform not in ("darwin", "win32")
|
||||
and shutil.which("gnome-screenshot")
|
||||
):
|
||||
fh, filepath = tempfile.mkstemp(".png")
|
||||
os.close(fh)
|
||||
subprocess.call(["gnome-screenshot", "-f", filepath])
|
||||
if shutil.which("gnome-screenshot"):
|
||||
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.load()
|
||||
os.unlink(filepath)
|
||||
|
|
Loading…
Reference in New Issue
Block a user