|
8 | 8 |
|
9 | 9 |
|
10 | 10 | class Window(BaseWindow):
|
| 11 | + """ |
| 12 | + Window using PyQt5. |
| 13 | +
|
| 14 | + This is the recommended window if you want your project to work |
| 15 | + on most platforms out of the box without any binary dependecies. |
| 16 | + """ |
11 | 17 | keys = Keys
|
12 | 18 |
|
13 | 19 | def __init__(self):
|
| 20 | + """ |
| 21 | + Creates a pyqt application and window overriding the |
| 22 | + built in event loop. Sets up keyboard and mouse events |
| 23 | + and creates a ``monderngl.Context``. |
| 24 | + """ |
14 | 25 | super().__init__()
|
15 | 26 | self._closed = False
|
16 | 27 |
|
@@ -73,31 +84,62 @@ def __init__(self):
|
73 | 84 | self.set_default_viewport()
|
74 | 85 |
|
75 | 86 | def keyPressEvent(self, event):
|
| 87 | + """ |
| 88 | + Pyqt specific key press callback function. |
| 89 | + Translates and forwards events to :py:func:`keyboard_event`. |
| 90 | + """ |
76 | 91 | self.keyboard_event(event.key(), self.keys.ACTION_PRESS, 0)
|
77 | 92 |
|
78 | 93 | def keyReleaseEvent(self, event):
|
| 94 | + """ |
| 95 | + Pyqt specific key release callback function. |
| 96 | + Translates and forwards events to :py:func:`keyboard_event`. |
| 97 | + """ |
79 | 98 | self.keyboard_event(event.key(), self.keys.ACTION_RELEASE, 0)
|
80 | 99 |
|
81 | 100 | def mouseMoveEvent(self, event):
|
| 101 | + """ |
| 102 | + Pyqt specific mouse event callback |
| 103 | + Translates and forwards events to :py:func:`cursor_event`. |
| 104 | + """ |
82 | 105 | self.cursor_event(event.x(), event.y(), 0, 0)
|
83 | 106 |
|
84 | 107 | def resizeGL(self, width, height):
|
| 108 | + """ |
| 109 | + Pyqt specific resize callback. |
| 110 | + The window currently do not support resizing. |
| 111 | + """ |
85 | 112 | print("Resize", width, height)
|
86 | 113 |
|
87 | 114 | def swap_buffers(self):
|
| 115 | + """ |
| 116 | + Swaps buffers, increments the frame counter and pulls events |
| 117 | + """ |
88 | 118 | self.frames += 1
|
89 | 119 | self.widget.swapBuffers()
|
90 | 120 | # We don't use standard event loop having to manually process events
|
91 | 121 | self.app.processEvents()
|
92 | 122 |
|
93 | 123 | def use(self):
|
| 124 | + """ |
| 125 | + Make the window's framebuffer the current render target |
| 126 | + """ |
94 | 127 | self.fbo.use()
|
95 | 128 |
|
96 |
| - def should_close(self): |
| 129 | + def should_close(self) -> bool: |
| 130 | + """ |
| 131 | + Checks if the internal close state is set |
| 132 | + """ |
97 | 133 | return self._closed
|
98 | 134 |
|
99 | 135 | def close(self):
|
| 136 | + """ |
| 137 | + Set the internal close state |
| 138 | + """ |
100 | 139 | self._closed = True
|
101 | 140 |
|
102 | 141 | def terminate(self):
|
| 142 | + """ |
| 143 | + Quits the running qt application |
| 144 | + """ |
103 | 145 | QtCore.QCoreApplication.instance().quit()
|
0 commit comments