-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchessactivity.py
55 lines (44 loc) · 1.4 KB
/
chessactivity.py
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
44
45
46
47
48
49
50
51
52
53
54
import sys
import os
from sugargame.canvas import PygameCanvas
import gobject
import gettext
from gettext import gettext as _
from sugar.activity import activity
from main import CeibalChess, log
class ChessActivity(activity.Activity):
'''
ChessActivity provides the basic configuration for
setting up and running Ceibal-Chess as an Activity and
for embedding pygame in a gtk window.
For all the methods of activity.Activity please visit:
http://api.sugarlabs.org/epydocs/sugar.activity.activity-pysrc.html
For the logic behind the GTK-pygame wrapping, visit:
http://wiki.sugarlabs.org/go/Development_Team/Sugargame
'''
def __init__(self, handle):
# i18n:
bundle_path = os.environ["SUGAR_BUNDLE_PATH"]
i18n_path = os.path.join(bundle_path, "po")
gettext.bindtextdomain("messages", i18n_path)
gettext.textdomain("messages")
activity.Activity.__init__(self, handle)
self.canvas = PygameCanvas(self)
self.set_canvas(self.canvas)
self.chess = CeibalChess()
self.chess.set_close_callback(self.close)
self.show()
gobject.idle_add(self.start_cb, None)
#rc = CeibalChess().start(1200, 900)
#sys.exit(rc)
def start_cb(self, param):
log.info("Starting pygame widget...")
self.canvas.run_pygame(self.chess.start)
def read_file(self, filepath):
pass
def write_file(self, filepath):
pass
def can_close(self):
log.info("Activity requested to stop...")
self.chess.stop()
return True