Window

class glumpy.app.window.Window(width=256, height=256, title=None, visible=True, aspect=None, decoration=True, fullscreen=False, config=None, context=None, color=(0, 0, 0, 1))

Bases: glumpy.app.window.event.EventDispatcher

Platform independent window.

Parameters:
  • 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:

Keyboard:

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

Mouse:

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

Window:

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
activate()

Activate window

clear(color=None, clearflags=None)

Clear the whole window

close()

Close (destroy) the window

color

Window clear color (read/write)

fps

Frame per second (read-only).

get_fullscreen()

Get window fullscreen mode

get_position()

Get window position

get_size()

Get window size

get_title()

Get window title

height

Window height (pixels, read-only)

hide()

Hide the window

on_init()

Window initialization

on_key_press(k, modifiers)

” Default key handler that close window on escape

on_resize(width, height)

” Default resize handler that set viewport

set_fullscreen(fullsrceen)

Set window fullscreen mode

set_position(x, y)

Set window position

set_size(width, height)

Set window size

set_title(title)

Set window title

show()

Make the window visible

swap()

Swap GL buffers

timer(delay)

Function decorator for timed handlers.

Parameters:
delay: int

Delay in second

Usage:

window = window.Window()

@window.timer(0.1)
def timer(dt):
    do_something ...
width

Window width (pixels, read-only)