Esempio n. 1
0
 def play(self):
     if not self._data:
         return
     self._channel = self._data.play()
     # schedule event to check if the sound is still playing or not
     pymt.getClock().schedule_interval(self._check_play, 0.1)
     super(SoundPygame, self).play()
Esempio n. 2
0
 def play(self):
     if not self._data:
         return
     self._channel = self._data.play()
     # schedule event to check if the sound is still playing or not
     pymt.getClock().schedule_interval(self._check_play, 0.1)
     super(SoundPygame, self).play()
Esempio n. 3
0
 def stop(self):
     if not self._data:
         return
     self._data.stop()
     # ensure we don't have anymore the callback
     pymt.getClock().unschedule(self._check_play)
     self._channel = None
     super(SoundPygame, self).stop()
Esempio n. 4
0
 def stop(self):
     if not self._data:
         return
     self._data.stop()
     # ensure we don't have anymore the callback
     pymt.getClock().unschedule(self._check_play)
     self._channel = None
     super(SoundPygame, self).stop()
Esempio n. 5
0
def test_runpymt(*largs, **kwargs):
    from pymt import runTouchApp, curry, getClock, stopTouchApp
    kwargs.setdefault('frame', 1)

    class testinfo(object):
        frame = kwargs.get('frame') + 1

    def test_runpymt_stop(info, *largs):
        info.frame -= 1
        if info.frame == 0:
            stopTouchApp()

    getClock().schedule_interval(curry(test_runpymt_stop, testinfo), 0)
    runTouchApp(*largs)
Esempio n. 6
0
def test_runpymt(*largs, **kwargs):
    from pymt import runTouchApp, curry, getClock, stopTouchApp
    kwargs.setdefault('frame', 1)

    class testinfo(object):
        frame = kwargs.get('frame') + 1

    def test_runpymt_stop(info, *largs):
        info.frame -= 1
        if info.frame == 0:
            stopTouchApp()

    getClock().schedule_interval(curry(test_runpymt_stop, testinfo), 0)
    runTouchApp(*largs)
Esempio n. 7
0
    def draw(self):
        t = getClock().get_time()
        touches = getCurrentTouches()

        # draw closed touches
        to_delete = []
        ids = [touch.id for touch in touches]
        for id in self.closetouches:
            if not id in ids:
                to_delete.append(id)
                continue
            touch = self.closetouches[id]
            value = ((t - touch.time_start) - 1) / 2.
            if value > 1:
                self.do_close()
                return
            set_color(1, 1, 1, .7)
            drawSemiCircle(pos=(touch.x, touch.y),
                           inner_radius=30,
                           outer_radius=50,
                           slices=64,
                           sweep_angle=value * 360)

        # delete old touches
        for id in to_delete:
            del self.closetouches[id]

        # search
        for touch in touches:
            if 'closeapp.invalid_for_close' in touch.userdata:
                continue
            # distance < 20
            if Vector(touch.osxpos, touch.osypos).distance(
                    Vector(touch.sx, touch.sy)) > 0.015:
                # flag
                touch.userdata['closeapp.invalid_for_close'] = True
                if touch.id in self.closetouches:
                    del self.closetouches[touch.id]
                return
            # 1s minimum
            if t - touch.time_start < 1:
                if touch.id in self.closetouches:
                    del self.closetouches[touch.id]
                return
            # check corner screen
            if touch.sx < .75 or touch.sy < .75:
                if touch.id in self.closetouches:
                    del self.closetouches[touch.id]
                return
            # add touches to closed touches
            self.closetouches[touch.id] = touch
Esempio n. 8
0
    def draw(self):
        t = getClock().get_time()
        touches = getCurrentTouches()

        # draw closed touches
        to_delete = []
        ids = [touch.id for touch in touches]
        for id in self.closetouches:
            if not id in ids:
                to_delete.append(id)
                continue
            touch = self.closetouches[id]
            value = ((t - touch.time_start) - 1) / 2.
            if value > 1:
                self.do_close()
                return
            set_color(1, 1, 1, .7)
            drawSemiCircle(pos=(touch.x, touch.y), inner_radius=30, outer_radius=50, slices=64, sweep_angle=value*360)

        # delete old touches
        for id in to_delete:
            del self.closetouches[id]

        # search
        for touch in touches:
            if 'closeapp.invalid_for_close' in touch.userdata:
                continue
            # distance < 20
            if Vector(*touch.opos).distance(Vector(touch.sx, touch.sy)) > 0.015:
                # flag
                touch.userdata['closeapp.invalid_for_close'] = True
                if touch.id in self.closetouches:
                    del self.closetouches[touch.id]
                return
            # 1s minimum
            if t - touch.time_start < 1:
                if touch.id in self.closetouches:
                    del self.closetouches[touch.id]
                return
            # check corner screen
            if touch.sx < .75 or touch.sy < .75:
                if touch.id in self.closetouches:
                    del self.closetouches[touch.id]
                return
            # add touches to closed touches
            self.closetouches[touch.id] = touch
Esempio n. 9
0
File: video.py Progetto: azoon/pymt
 def on_touch_down(self, touch):
     if self.collide_point(touch.x, touch.y):
         self.show_controls()
         self._count += 1
         pymt.getClock().schedule_once(self._try_hide_controls, 5)
     return super(MTVideo, self).on_touch_down(touch)