mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-04-09 20:04:14 +03:00
Merge pull request #8842 from AdianKozlica/image_grab_wayland_kde
Add KDE Wayland support for ImageGrab
This commit is contained in:
commit
7c56b383ff
|
@ -40,8 +40,10 @@ 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()
|
||||
|
|
|
@ -16,8 +16,9 @@ or the clipboard to a PIL image memory.
|
|||
the entire screen is copied, and on macOS, it will be at 2x if on a Retina screen.
|
||||
|
||||
On Linux, if ``xdisplay`` is ``None`` and the default X11 display does not return
|
||||
a snapshot of the screen, ``gnome-screenshot`` will be used as fallback if it is
|
||||
installed. To disable this behaviour, pass ``xdisplay=""`` instead.
|
||||
a snapshot of the screen, ``gnome-screenshot`` or ``spectacle`` will be used as a
|
||||
fallback if they are installed. To disable this behaviour, pass ``xdisplay=""``
|
||||
instead.
|
||||
|
||||
.. versionadded:: 1.1.3 (Windows), 3.0.0 (macOS), 7.1.0 (Linux)
|
||||
|
||||
|
|
|
@ -86,14 +86,16 @@ def grab(
|
|||
raise OSError(msg)
|
||||
size, data = Image.core.grabscreen_x11(display_name)
|
||||
except OSError:
|
||||
if (
|
||||
display_name is None
|
||||
and sys.platform not in ("darwin", "win32")
|
||||
and shutil.which("gnome-screenshot")
|
||||
):
|
||||
if display_name is None and sys.platform not in ("darwin", "win32"):
|
||||
if shutil.which("gnome-screenshot"):
|
||||
args = ["gnome-screenshot", "-f"]
|
||||
elif shutil.which("spectacle"):
|
||||
args = ["spectacle", "-n", "-b", "-f", "-o"]
|
||||
else:
|
||||
raise
|
||||
fh, filepath = tempfile.mkstemp(".png")
|
||||
os.close(fh)
|
||||
subprocess.call(["gnome-screenshot", "-f", filepath])
|
||||
subprocess.call(args + [filepath])
|
||||
im = Image.open(filepath)
|
||||
im.load()
|
||||
os.unlink(filepath)
|
||||
|
|
Loading…
Reference in New Issue
Block a user