Window(width=256, height=256, title=None, visible=True, aspect=None, decoration=True, fullscreen=False, config=None, context=None, color=(0, 0, 0, 1))¶
Platform independent window.
- width (int) – Initial width (pixels)
- height (int) – Initial height (pixels)
- strtitle – Window title
- visible (bool) – Initial visibility status
- decoration (bool) – Whether window is decorated
- fullscreen (bool) – Initial fullscreen status
- config – GL Configuration
- context (Window) – Window to share GL context with
- color (4-tuple) – Clear color
The content area of a window is filled entirely with an OpenGL viewport. Applications have no access to operating system widgets or controls; all rendering must be done via OpenGL.
Windows may appear as floating regions or can be set to fill an entire screen (fullscreen). When floating, windows may appear borderless or decorated with a platform-specific frame (including, for example, the title bar, minimize and close buttons, resize handles, and so on).
While it is possible to set the location of a window, it is recommended that applications allow the platform to place it according to local conventions. This will ensure it is not obscured by other windows, and appears on an appropriate screen for the user.
It is the responsability of the window backend to dispatch the following events when necessary:
def on_key_press(symbol, modifiers): 'A key on the keyboard was pressed.' pass def on_key_release(symbol, modifiers): 'A key on the keyboard was released.' pass def on_character(text): 'A character has been typed' pass
def on_mouse_press(self, x, y, button): 'A mouse button was pressed.' pass def on_mouse_release(self, x, y, button): 'A mouse button was released.' pass def on_mouse_motion(x, y, dx, dy): 'The mouse was moved with no buttons held down.' pass def on_mouse_drag(x, y, dx, dy, buttons): 'The mouse was moved with some buttons pressed.' pass def on_mouse_scroll(self, dx, dy): 'The mouse wheel was scrolled by (dx,dy).' pass
def on_init(self): 'The window has just initialized iself.' pass def on_show(self): 'The window was shown.' pass def on_hide(self): 'The window was hidden.' pass def on_close(self): 'The user closed the window.' pass def on_resize(self, width, height): 'The window was resized to (width,height)' pass def on_draw(self, dt): 'The window contents must be redrawn.' pass def on_idle(self, dt): 'The window is inactive.' pass
Clear the whole window
Close (destroy) the window
Window clear color (read/write)
Frame per second (read-only).
Get window fullscreen mode
Get window position
Get window size
Get window title
Window height (pixels, read-only)
Hide the window
” Default key handler that close window on escape
” Default resize handler that set viewport
Set window fullscreen mode
Set window position
Set window size
Set window title
Make the window visible
Swap GL buffers
Function decorator for timed handlers.
Delay in second
window = window.Window() @window.timer(0.1) def timer(dt): do_something ...
Window width (pixels, read-only)