blob: fdaa0f9943d13c8a41f192c73efb094a14ea106a (
plain)
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
|
# activity.py
# my standard link between sugar and my activity
from gettext import gettext as _
import gtk
import pygame
from sugar.activity import activity
from sugar.graphics.toolbutton import ToolButton
import gobject
import sugargame.canvas
import load_save
import FollowMe
class PeterActivity(activity.Activity):
def __init__(self, handle):
super(PeterActivity, self).__init__(handle)
# Build the activity toolbar.
toolbox = activity.ActivityToolbox(self)
activity_toolbar = toolbox.get_activity_toolbar()
activity_toolbar.keep.props.visible = False
activity_toolbar.share.props.visible = False
toolbox.show()
self.set_toolbox(toolbox)
# Create the game instance.
self.game = FollowMe.FollowMe()
# Build the Pygame canvas.
self._pygamecanvas = \
sugargame.canvas.PygameCanvas(self)
# Note that set_canvas implicitly calls
# read_file when resuming from the Journal.
self.set_canvas(self._pygamecanvas)
self.game.canvas=self._pygamecanvas
# Start the game running.
self._pygamecanvas.run_pygame(self.game.run)
def read_file(self, file_path):
try:
f = open(file_path, 'r')
except:
return #****
load_save.load(f)
f.close()
def write_file(self, file_path):
f = open(file_path, 'w')
load_save.save(f)
f.close()
|