|
12 | 12 |
|
13 | 13 | The Window class (formerly known as _sdl2.video.Window), is an experimental
|
14 | 14 | feature of pygame-ce. This class allows for programs to drive multiple
|
15 |
| - Windows on-screen at once, something not possible with the |
| 15 | + Windows on-screen at once, something not possible with the |
16 | 16 | :func:`pygame.display.set_mode` API. Not everything possible with
|
17 | 17 | :mod:`pygame.display` is possible yet in the Window API, but the new
|
18 | 18 | window class will continue to be developed, and we're excited to share
|
|
26 | 26 | the resolution (videomode change).
|
27 | 27 | :param bool fullscreen_desktop: Create a fullscreen window using the current
|
28 | 28 | desktop resolution.
|
29 |
| - :param bool opengl: Create a window with support for an OpenGL context. You |
30 |
| - will still need to create an OpenGL context separately. |
| 29 | + :param bool opengl: Create a window with support for an OpenGL context. |
31 | 30 | :param bool vulkan: Create a window with support for a Vulkan instance.
|
32 | 31 | :param bool hidden: Create a hidden window.
|
33 | 32 | :param bool borderless: Create a window without borders.
|
|
46 | 45 | others.
|
47 | 46 |
|
48 | 47 | .. versionadded:: 2.4.0
|
| 48 | + .. versionchanged:: 2.5.0 when ``opengl`` is ``True``, the ``Window`` has an OpenGL context created by pygame |
49 | 49 |
|
50 | 50 |
|
51 | 51 | .. attribute:: grab_mouse
|
|
63 | 63 | .. seealso:: :attr:`mouse_grabbed`
|
64 | 64 |
|
65 | 65 | .. versionadded:: 2.4.0
|
66 |
| - |
| 66 | + |
67 | 67 | .. attribute:: grab_keyboard
|
68 | 68 |
|
69 | 69 | | :sl:`Get or set the window's keyboard grab mode`
|
70 | 70 | | :sg:`grab_keyboard -> bool`
|
71 |
| - |
72 |
| - When this attribute is set to ``True``, the window will try to capture system |
73 |
| - keyboard shortcuts like ``Alt+Tab`` or the ``Meta/Super`` key. |
| 71 | +
|
| 72 | + When this attribute is set to ``True``, the window will try to capture system |
| 73 | + keyboard shortcuts like ``Alt+Tab`` or the ``Meta/Super`` key. |
74 | 74 |
|
75 | 75 | This attribute only set the "mode" of grab. The keyboard may be captured by
|
76 |
| - another window depending on the window focus. To get if keyboard is currently |
| 76 | + another window depending on the window focus. To get if keyboard is currently |
77 | 77 | captured by this window, please use :attr:`keyboard_grabbed`.
|
78 |
| - |
| 78 | + |
79 | 79 | Note that not all system keyboard shortcuts can be captured by applications
|
80 | 80 | (one example is ``Ctrl+Alt+Del`` on Windows).
|
81 | 81 |
|
|
90 | 90 | .. seealso:: :attr:`keyboard_grabbed`
|
91 | 91 |
|
92 | 92 | .. versionadded:: 2.4.0
|
93 |
| - |
| 93 | + |
94 | 94 | .. attribute:: mouse_grabbed
|
95 | 95 |
|
96 | 96 | | :sl:`Get if the mouse cursor is confined to the window (**read-only**)`
|
|
99 | 99 | Get if the mouse cursor is currently grabbed and confined to the window.
|
100 | 100 |
|
101 | 101 | Roughly equivalent to this expression:
|
102 |
| - |
| 102 | + |
103 | 103 | ::
|
104 | 104 |
|
105 | 105 | win.grab_mouse and (win is get_grabbed_window())
|
106 |
| - |
| 106 | + |
107 | 107 | .. seealso:: :attr:`grab_mouse`
|
108 |
| - |
| 108 | + |
109 | 109 | .. versionadded:: 2.4.0
|
110 |
| - |
| 110 | + |
111 | 111 | .. attribute:: keyboard_grabbed
|
112 | 112 |
|
113 | 113 | | :sl:`Get if the keyboard shortcuts are captured by the window (**read-only**)`
|
|
116 | 116 | Get if the keyboard shortcuts are currently grabbed and captured by the window.
|
117 | 117 |
|
118 | 118 | Roughly equivalent to this expression:
|
119 |
| - |
| 119 | + |
120 | 120 | ::
|
121 | 121 |
|
122 | 122 | win.grab_keyboard and (win is get_grabbed_window())
|
123 |
| - |
| 123 | + |
124 | 124 | This attribute requires SDL 2.0.16+.
|
125 |
| - |
| 125 | + |
126 | 126 | .. seealso:: :attr:`grab_keyboard`
|
127 |
| - |
| 127 | + |
128 | 128 | .. versionadded:: 2.4.0
|
129 | 129 |
|
130 | 130 | .. attribute:: title
|
|
147 | 147 | Gets or sets whether the window is borderless.
|
148 | 148 |
|
149 | 149 | .. note:: You can't change the border state of a fullscreen window.
|
150 |
| - |
| 150 | + |
151 | 151 | .. attribute:: always_on_top
|
152 | 152 |
|
153 | 153 | | :sl:`Get or set whether the window is always on top`
|
|
163 | 163 |
|
164 | 164 | | :sl:`Get the unique window ID (**read-only**)`
|
165 | 165 | | :sg:`id -> int`
|
166 |
| - |
| 166 | +
|
167 | 167 | .. attribute:: mouse_rect
|
168 | 168 |
|
169 | 169 | | :sl:`Get or set the mouse confinement rectangle of the window`
|
|
173 | 173 | cursor to the specified area of this window.
|
174 | 174 |
|
175 | 175 | This attribute can be None, meaning that there is no mouse rect.
|
176 |
| - |
| 176 | + |
177 | 177 | Note that this does NOT grab the cursor, it only defines the area a
|
178 | 178 | cursor is restricted to when the window has mouse focus.
|
179 | 179 |
|
|
183 | 183 |
|
184 | 184 | | :sl:`Get or set the window size in pixels`
|
185 | 185 | | :sg:`size -> (int, int)`
|
186 |
| - |
| 186 | +
|
187 | 187 | .. attribute:: minimum_size
|
188 | 188 |
|
189 | 189 | | :sl:`Get or set the minimum size of the window's client area`
|
|
193 | 193 | was used to create the window and :func:`pygame.display.set_mode` was
|
194 | 194 | called with the ``SCALED`` flag, the initial value is the size used in
|
195 | 195 | that call.
|
196 |
| - |
197 |
| - Raises a ``ValueError`` if negative values are provided or |
198 |
| - if the width or height provided are greater than set |
199 |
| - maximum width or height respectively. Unless maximum size |
| 196 | + |
| 197 | + Raises a ``ValueError`` if negative values are provided or |
| 198 | + if the width or height provided are greater than set |
| 199 | + maximum width or height respectively. Unless maximum size |
200 | 200 | is ``(0, 0)`` (initial value).
|
201 | 201 |
|
202 | 202 | .. seealso:: :attr:`maximum_size`.
|
203 | 203 |
|
204 | 204 | .. versionadded:: 2.4.0
|
205 |
| - |
| 205 | + |
206 | 206 | .. attribute:: maximum_size
|
207 | 207 |
|
208 | 208 | | :sl:`Get or set the maximum size of the window's client area`
|
209 | 209 | | :sg:`maximum_size -> (int, int)`
|
210 | 210 |
|
211 | 211 | Initial value is ``(0, 0)``.
|
212 | 212 |
|
213 |
| - Raises a ``ValueError`` if negative values are provided or |
214 |
| - if the width or height provided are less than set minimum |
| 213 | + Raises a ``ValueError`` if negative values are provided or |
| 214 | + if the width or height provided are less than set minimum |
215 | 215 | width or height respectively.
|
216 | 216 |
|
217 | 217 | .. seealso:: :attr:`minimum_size`.
|
|
228 | 228 | | :sl:`Get or set the window opacity, between 0.0 (fully transparent) and 1.0 (fully opaque)`
|
229 | 229 | | :sg:`opacity -> float`
|
230 | 230 |
|
| 231 | + .. attribute:: opengl |
| 232 | + |
| 233 | + | :sl:`Get if the window supports OpenGL` |
| 234 | + | :sg:`opengl -> bool` |
| 235 | +
|
| 236 | + ``True`` if the ``Window`` has an OpenGL context associated with it, ``False`` otherwise |
| 237 | + |
| 238 | + .. versionadded:: 2.5.0 |
| 239 | + |
231 | 240 | .. classmethod:: from_display_module
|
232 | 241 |
|
233 | 242 | | :sl:`Create a Window object using window data from display module`
|
|
256 | 265 | Similarly to the "display surface" returned by :mod:`pygame.display`,
|
257 | 266 | this surface will change size with the Window, and will become invalid
|
258 | 267 | after the Window's destruction.
|
259 |
| - |
| 268 | + |
260 | 269 | .. seealso:: :func:`flip`
|
261 | 270 |
|
262 | 271 | .. versionadded:: 2.4.0
|
263 |
| - |
| 272 | + |
264 | 273 | .. method:: flip
|
265 | 274 |
|
266 | 275 | | :sl:`Update the display surface to the window.`
|
267 | 276 | | :sg:`flip() -> None`
|
268 | 277 |
|
269 |
| - Update content from the display surface to the window. This is the Window |
| 278 | + Update pixel data from memory to be displayed in the window. This is the Window |
270 | 279 | class equivalent of :func:`pygame.display.flip`.
|
271 | 280 |
|
272 |
| - This method allows software rendering (classic pygame rendering) on top |
273 |
| - of the Window API. This method should not be called when using hardware |
274 |
| - rendering (coming soon). |
| 281 | + With ``get_surface()`` this method allows software rendering (classic pygame rendering) flipping pixel data |
| 282 | + from an associated surface in memory to be displayed in the window. Alternatively, when this window has an |
| 283 | + associated OpenGL context, this method will instead perform a GL buffer swap to the window. |
275 | 284 |
|
276 | 285 | Here is a runnable example of using ``get_surface`` and ``flip``:
|
277 | 286 |
|
|
355 | 364 | | :sl:`Maximize the window`
|
356 | 365 | | :sg:`maximize() -> None`
|
357 | 366 |
|
358 |
| - .. method:: minimize |
| 367 | + .. method:: minimize |
359 | 368 |
|
360 | 369 | | :sl:`Minimize the window`
|
361 | 370 | | :sg:`maximize() -> None`
|
|
375 | 384 | | :sg:`set_modal_for(parent, /) -> None`
|
376 | 385 |
|
377 | 386 | :param Window parent: The parent window.
|
378 |
| - |
| 387 | + |
379 | 388 | .. note:: This function is only supported on X11.
|
380 | 389 |
|
381 | 390 | .. ## pygame.Window ##
|
0 commit comments