Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Maze.activity/activity.py
diff options
context:
space:
mode:
Diffstat (limited to 'Maze.activity/activity.py')
-rwxr-xr-xMaze.activity/activity.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/Maze.activity/activity.py b/Maze.activity/activity.py
index ceb205c..4b088c9 100755
--- a/Maze.activity/activity.py
+++ b/Maze.activity/activity.py
@@ -1,6 +1,34 @@
import olpcgames
+import pygame
+from sugar.graphics.toolbutton import ToolButton
+from gettext import gettext as _
class MazeActivity(olpcgames.PyGameActivity):
game_name = 'game'
game_title = 'Maze'
game_size = None # let olpcgames pick a nice size for us
+
+ def build_toolbar( self ):
+ """Build our Activity toolbar for the Sugar system."""
+ toolbar = super( MazeActivity, self ).build_toolbar()
+
+ # Add buttons that will make the maze harder or easier
+ toolbar.harder = ToolButton('activity-harder')
+ toolbar.harder.set_tooltip(_('Harder'))
+ toolbar.harder.connect('clicked', self._harder_cb)
+ toolbar.insert(toolbar.harder, 2)
+ toolbar.harder.show()
+
+ toolbar.easier = ToolButton('activity-easier')
+ toolbar.easier.set_tooltip(_('Easier'))
+ toolbar.easier.connect('clicked', self._easier_cb)
+ toolbar.insert(toolbar.easier, 2)
+ toolbar.easier.show()
+
+ return toolbar
+
+ def _harder_cb(self, button):
+ pygame.event.post(olpcgames.eventwrap.Event(pygame.USEREVENT, action='harder'))
+
+ def _easier_cb(self, button):
+ pygame.event.post(olpcgames.eventwrap.Event(pygame.USEREVENT, action='easier'))