Package libavg :: Module AVGApp'

Source Code for Module libavg.AVGApp'

 1  # libavg - Media Playback Engine. 
 2  # Copyright (C) 2003-2008 Ulrich von Zadow 
 3  # 
 4  # This library is free software; you can redistribute it and/or 
 5  # modify it under the terms of the GNU Lesser General Public 
 6  # License as published by the Free Software Foundation; either 
 7  # version 2 of the License, or (at your option) any later version. 
 8  # 
 9  # This library is distributed in the hope that it will be useful, 
10  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
11  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12  # Lesser General Public License for more details. 
13  # 
14  # You should have received a copy of the GNU Lesser General Public 
15  # License along with this library; if not, write to the Free Software 
16  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
17  # 
18  # Current versions can be found at www.libavg.de 
19  # 
20  # Original author of this file is Martin Heistermann <mh at sponc dot de> 
21  # 
22   
23  import os 
24 25 -class AVGApp(object):
26 multitouch = False
27 - def __init__(self, parentNode):
28 """initialization before Player.play() 29 Use this only when needed, e.g. for 30 Words.addFontDir(). Do not forget to call 31 super(YourApp, self).__init__(parentNode)""" 32 self.__isRunning = False 33 self._parentNode = parentNode 34 self._starter = None
35
36 - def init(self):
37 """main initialization 38 build node hierarchy under self.__parentNode.""" 39 pass
40
41 - def _enter(self):
42 """enter the application, internal interface. 43 override this and start all animations, intervals 44 etc. here""" 45 pass
46
47 - def _leave(self):
48 """leave the application, internal interface. 49 override this and stop all animations, intervals 50 etc. Take care your application does not use any 51 non-needed resources after this.""" 52 pass
53
54 - def enter(self, onLeave = lambda: None):
55 """enter the application, external interface. 56 Do not override this.""" 57 self.__isRunning = True 58 self._onLeave = onLeave 59 self._enter()
60
61 - def leave(self):
62 """leave the application, external interface. 63 Do not override this.""" 64 self.__isRunning = False 65 self._onLeave() 66 self._leave()
67
68 - def onKey(self, event):
69 """returns bool indicating if the event was handled 70 by the application """ 71 return False
72
73 - def isRunning(self):
74 return self.__isRunning
75
76 - def setStarter(self, starter):
77 self._starter = starter
78 79 @classmethod
80 - def start(cls, *args, **kwargs):
81 from AVGAppStarter import AVGAppStarter 82 from AVGMTAppStarter import AVGMTAppStarter 83 if cls.multitouch: 84 starter = AVGMTAppStarter 85 else: 86 starter = AVGAppStarter 87 return starter(appClass = cls, *args, **kwargs)
88