Base: Main event loop, provider creation, window management...

# Jump directly to Examples

Base: Main event loop, provider creation, window management...

pymt.base.pymt_usage()

PyMT Usage: %s [OPTION...]

-h, --help                  prints this mesage
-f, --fullscreen            force run in fullscreen
-k, --fake-fullscreen       force run in 'fake' fullscreen (no border mode)
-a, --auto-fullscreen       force run in 'auto' fullscreen (no resolution change)
-w, --windowed              force run in window
-p, --provider id:provider[,options] add a provider (eg: ccvtable1:tuio,192.168.0.1:3333)
-F, --fps                   show fps in window
-m mod, --module=mod        activate a module (use "list" to get available module)
-s, --save                  save current PyMT configuration
--size=640x480              size of window
pymt.base.runTouchApp(widget=None, slave=False)

Static main function that starts the application loop. You got some magic things, if you are using argument like this :

Parameters :
<empty>

To make dispatching work, you need at least one input listener. If not, application will leave. (MTWindow act as an input listener)

widget

If you pass only a widget, a MTWindow will be created, and your widget will be added on the window as the root widget.

slave

No event dispatching are done. This will be your job.

widget + slave

No event dispatching are done. This will be your job, but we are trying to get the window (must be created by you before), and add the widget on it. Very usefull for embedding PyMT in another toolkit. (like Qt, check pymt-designed)

pymt.base.stopTouchApp()

Stop the current application by leaving the main loop

pymt.base.getFrameDt()

Return the last delta between old and new frame.

pymt.base.getCurrentTouches()

Return the list of all current touches

pymt.base.getEventLoop()

Return the default TouchEventLoop object

pymt.base.pymt_event_listeners

List of event listeners

pymt.base.touch_event_listeners

Deprecated since version 0.5: This symbol have been renamed to pymt_event_listeners

pymt.base.getWindow()

Return the MTWindow

pymt.base.setWindow(win)

Set current PyMT window .. warning:

Use it only if you know what you are doing !

Examples

File base_event_dispatcher.py

'''
Create a event dispatcher, and use it to get all event from PyMT
Without any OpenGL window created.
'''

# prevent window creation
import os

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

# create a class to catch all events
class TouchEventListener:
    def dispatch_event(self, event_name, *arguments):
        print 'Event dispatched', event_name, 'with', arguments

# append the class to event listeners
pymt_event_listeners.append(TouchEventListener())

# start pymt subsystem
runTouchApp(slave=True)

# now you can run your application,
# and don't forget to update PyMT subsystem
while True:
    # update pymt subsystem
    getEventLoop().idle()

    # do your own thing.
    pass