File: main_loop.py

package info (click to toggle)
soya 0.12-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 13,580 kB
  • ctags: 20,171
  • sloc: cpp: 45,252; python: 7,241; ansic: 5,226; perl: 273; makefile: 227; sh: 65
file content (43 lines) | stat: -rw-r--r-- 965 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# -*- indent-tabs-mode: t -*-

""" a simple replacement main_loop for soya """

__revision__ = '$Revision: 1.1 $'

__doc_classes__ = [ 'MainLoop' ] 

__doc_functions__ = []

import soya
from soya.pudding import process_event

import unittest

class MainLoop(soya.MainLoop):
	""" Simple replacement for the soya.MainLoop that calls soya.pudding.process_event
	in begin_round and places all unhandled events into main_loop.events.
	
	"""

	def __init__(self, *scenes):
		soya.MainLoop.__init__(self, *scenes)

		self.events = []

	def begin_round(self):
		""" call soya.pudding.process event and put all events in self.events so the 
		"game" can handle other events """

		soya.MainLoop.begin_round(self)

		self.events = process_event()

	def main_loop(self):
		""" resize all widgets and start the main_loop """
		soya.root_widget.on_resize()

		soya.MainLoop.main_loop(self)

class TestMainLoop(unittest.TestCase):
	def testCreate(self):
		main_loop = MainLoop()