Migrate from 0.2 to 0.3
| Migrate | Migrate from 0.3 to 0.3.1 |
In this document
New behaviors
- in widgets, to_local() is used for matrix transformation. to_local don't include anymore local translation.
New events signatures
| Old signature | New signature |
|---|---|
| on_touch_down(self, touches, touchID, x, y) | on_touch_down(self, touch) |
| on_touch_move(self, touches, touchID, x, y) | on_touch_move(self, touch) |
| on_touch_up(self, touches, touchID, x, y) | on_touch_up(self, touch) |
| on_press(self, touchID, x, y) | on_press(self, touch) |
| on_release(self, touchID, x, y) | on_release(self, touch) |
| on_gesture(self, touchID, x, y) | on_gesture(self, touch) |
The touch argument is a class derivated from the Touch class. You can access to property like: touch.x, touch.y, touch.id
If you have an examples like :
if self.collide_point(x, y):
self.touches.append(touchID)
You can rewrite it to :
if self.collide_point(touch.x, touch.y):
self.touches.append(touch.id)
If you want to access on old touches argument, you can use getAvailableTouchs() function.
Input configuration in configuration file
The section `[`tuio`]` is deleted. The new configuration section is `[`input`]`. The format is :
my_input_id = provider_id,arguments
my_input_id2 = provider_id,arguments
We have actually only one input provider available (more soon ^^): tuio. So, you can configure PyMT to listen more than one tuio source with a configuration like this :
default = tuio,127.0.0.1:3333
jimitable = tuio,192.168.0.125:3334
And, at start, PyMT will show :
[DEBUG ] Create provider from tuio,192.168.0.125:3334
[INFO ] listening for Tuio on 127.0.0.1:4567
[INFO ] listening for Tuio on 192.168.0.125:3334
Input configuration at command line
Options -H and -p are deleted. You've now only -p, --provider option, to modify or add a new provider at runtime. Syntax is:
So, if you want to change your default tuio input, you can do:
Or add new input provider :
myotherlcd:tuio,192.168.0.1:3335
Removed on_object_`*` events
Objects event are in on_touch_`*` event. You can access to the angle with touch.angle property. You can check if the touch have angle capability:
if 'a' in touch.profile:
# it's a touch with angle
Grab touch
A new thing on this is you can now Grab a touch !!!! Wait, grab ? Yes. When a touch is down, you can "grab it", and receive all event, what ever is the position or collision on parent. (even if the touch is outside bounding box of parent for example.)
Eg:
touch.grab(self)
def on_touch_up(self, touch):
touch.ungrab(self)
