You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/api.rst
+36-5Lines changed: 36 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,12 @@ GNU/Linux
10
10
11
11
.. module:: mss.linux
12
12
13
+
.. attribute:: LAST_ERROR
14
+
15
+
:type: dict[str, Any]
16
+
17
+
Contains the latest Xlib or XRANDR function.
18
+
13
19
.. class:: MSS
14
20
15
21
.. method:: __init__([display=None])
@@ -25,6 +31,33 @@ GNU/Linux
25
31
26
32
.. versionadded:: 4.0.0
27
33
34
+
.. method:: get_error_details()
35
+
36
+
:rtype: Optional[dict[str, Any]]
37
+
38
+
Get more information about the latest X server error. To use in such scenario::
39
+
40
+
with mss.mss() as sct:
41
+
# Take a screenshot of a region out of monitor bounds
42
+
rect = {"left": -30, "top": 0, "width": 100, "height": 100}
43
+
44
+
try:
45
+
sct.grab(rect)
46
+
except ScreenShotError:
47
+
details = sct.get_error_details()
48
+
"""
49
+
>>> import pprint
50
+
>>> pprint.pprint(details)
51
+
{'xerror': 'BadFont (invalid Font parameter)',
52
+
'xerror_details': {'error_code': 7,
53
+
'minor_code': 0,
54
+
'request_code': 0,
55
+
'serial': 422,
56
+
'type': 0}}
57
+
"""
58
+
59
+
.. versionadded:: 4.0.0
60
+
28
61
.. method:: grab(monitor)
29
62
30
63
:rtype::class:`mss.base.ScreenShot`
@@ -43,7 +76,7 @@ GNU/Linux
43
76
Error handler passed to `X11.XSetErrorHandler()` to catch any error that can happen when calling a X11 function.
44
77
This will prevent Python interpreter crashes.
45
78
46
-
When such an error happen, a :class:`mss.exception.ScreenShotError` exception is raised and all XError information are added to the :attr:`mss.exception.ScreenShotError.details` attribute.
79
+
When such an error happen, a :class:`mss.exception.ScreenShotError` exception is raised and all `XError` information are added to the :attr:`mss.exception.ScreenShotError.details` attribute.
0 commit comments