Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/activity.py
diff options
context:
space:
mode:
Diffstat (limited to 'activity.py')
-rwxr-xr-xactivity.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/activity.py b/activity.py
new file mode 100755
index 0000000..fdaa0f9
--- /dev/null
+++ b/activity.py
@@ -0,0 +1,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()