Migrate from 0.3.1 to 0.4

Migrate from 0.3 to 0.3.1MigrateMigrate from 0.4 to 0.5

Configuration changes

  • display options is not working anymore.
  • fullscreen can have the value of :
    • 0: no fullscreen
    • 1: normal fullscreen, using width/height in configuration
    • auto: will take the current width/heigth of the screen
    • fake: will just display the window without border, and force position to 0, 0. You must adapt width and height

Pyglet removal

We don't use pyglet anymore. Prefer to use our library now ! If you really really want to stay on pyglet, you must import pyglet in a way to not break OpenGL :

import pyglet
pyglet.options['shadow_window'] = False

Otherwise, use our toolkit to load Image, Sound...

from pymt import *

# load a sound
sound = SoundLoader.load('mysound.ogg')
sound.play()

# load an image
image = Image.load('myimage.png')

# load a video
video = Video(filename='myvideo.mkv')
video.play()

# get webcam image
camera = Camera()

# USE a container to add on widget tree
getWindow().add_widget(MTContainer(image)) # image
getWindow().add_widget(MTContainer(video)) # video
getWindow().add_widget(MTContainer(camera)) # camera

# or use our special widget like MTVideo...

Clock event

Don't use pyglet, use our pymt.clock class.

from pymt import *

# get default pymt clock
clk = getClock()

# schedule an event
clk.schedule_interval(my_callback, 1) # will be called every seconds

Child iteration

The main bug with child iteration is that the list can be changed while iterating on it (remove / add a widget in on_update() traversal for example). So, we have created SafeList() class.

If you iterate on child, you must take care of that case to prevent bug. Instead of writing :

for child in self.children:
  pass

Replace to:

for child in self.children.iterate():
  pass

It's the same if you want to replace the whole childrens, don't remove the current list, do :

self.children.clear()
for new_child in my_new_children:
  self.children.append(new_child)

Window creation

PyMT create the window at import time. No need to use MTWindow() anymore. You have 2 way to run your applications now :

  • pass your root widget to runTouchApp()
  • add widget to default window before runTouchApp()
from pymt import *
m = MTVideo(filename='myvideo.mkv')
runTouchApp(m)

OR

from pymt import *
window = getWindow()
window.add_widget(MTVideo(filename='myvideo.mkv'))
runTouchApp()

Deprecated functions

  • getAvailableTouchs() -> getCurrentTouches()
  • <object>.get_texture() -> <object>.texture
  • MTScatter.get_scale_factor() -> MTScatter.scale