Window package: provide a window + a touch display

_REF

Window package: provide a window + a touch display

For windowing system, we try to use the best windowing system available for your system. Actually, theses libraries are handled :

  • PyGame (wrapper around SDL)
  • GLUT (last solution, really buggy :/)
class pymt.ui.window.BaseWindow(**kwargs)

Bases: pymt.event.EventDispatcher

BaseWindow is a abstract window widget, for any window implementation.

Warning

The parameters are not working in normal case. Because at import, PyMT create a default OpenGL window, to add the ability to use OpenGL directives, texture creation.. before creating MTWindow. If you don’t like this behavior, you can include before the very first import of PyMT

import os
os.environ['PYMT_SHADOW'] = '0'
from pymt import *

This will forbid PyMT to create the default window !

Parameters :
fullscreen: bool

Make window as fullscreen

width: int

Width of window

height: int

Height of window

vsync: bool

Vsync window

Styles :
bg-color: color

Background color of window

add_widget(w)

Add a widget on window

apply_css(styles)

Called at __init__ time to applied css attribute in current class.

clear()

Clear the window with background color

close()

Close the window

create_window(params)

Will create the main window and configure it

dispatch_events()

Dispatch all events from windows

draw()

Draw the window background

draw_mouse_touch()

Compatibility for MouseTouch, drawing a little red circle around under each mouse touches.

flip()

Flip between buffers

on_close(*largs)

Event called when the window is closed

on_draw()

Event called when window we are drawing window. This function are cleaning the buffer with bg-color css, and call children drawing + show fps timer on demand

on_flip()

Flip between buffers (event)

on_key_down(key, scancode=None, unicode=None)

Event called when a key is down (same arguments as on_keyboard)

on_key_up(key, scancode=None, unicode=None)

Event called when a key is up (same arguments as on_keyboard)

on_keyboard(key, scancode=None, unicode=None)

Event called when keyboard is in action

Warning

Some providers can skip scancode or unicode !!

on_mouse_down(x, y, button, modifiers)

Event called when mouse is in action (press/release)

on_mouse_move(x, y, modifiers)

Event called when mouse is moving, with buttons pressed

on_mouse_up(x, y, button, modifiers)

Event called when mouse is moving, with buttons pressed

on_resize(width, height)

Event called when the window is resized

on_touch_down(touch)

Event called when a touch is down

on_touch_move(touch)

Event called when a touch move

on_touch_up(touch)

Event called when a touch up

on_update()

Event called when window are update the widget tree. (Usually before on_draw call.)

reload_css()

Called when css want to be reloaded from scratch

remove_widget(w)

Remove a widget from window

toggle_fullscreen()

Toggle fullscreen on window

wallpaper

Get/set the wallpaper (must be a valid filename)

wallpaper_position

Get/set the wallpaper position (can be one of”norepeat”, “center”, “repeat”, “scale”, “strech”)

class pymt.ui.window.MTDisplay(**kwargs)

Bases: pymt.ui.widgets.widget.MTWidget

MTDisplay is a widget that draw a circle under every touch on window.

Parameters :
touch_color : list

Color of circle under finger

radius : int

Radius of circle under finger in pixel

Styles :
touch-color : color

Color of circle under finger

draw()

Draw a circle under every touches

Previous topic

XML widget: parse xml and create his children

Next topic

Animation package: handle animation with ease in PyMT

This Page