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')
-rw-r--r--activity.py28
1 files changed, 19 insertions, 9 deletions
diff --git a/activity.py b/activity.py
index 69011aa..58f9802 100644
--- a/activity.py
+++ b/activity.py
@@ -1,5 +1,14 @@
# activity.py
# my standard link between sugar and my activity
+"""
+ Copyright (C) 2010 Peter Hewitt
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+"""
from gettext import gettext as _
import logging
@@ -9,11 +18,10 @@ import gobject
from sugar.activity import activity
from sugar.graphics.toolbarbox import ToolbarBox
-from sugar.activity.widgets import ActivityToolbarButton
-from sugar.activity.widgets import StopButton
+from sugar.activity.widgets import ActivityToolbarButton, StopButton
from sugar.graphics.toolbarbox import ToolbarButton
from sugar.graphics.toolbutton import ToolButton
-from sugar.graphics import style
+from sugar.graphics.style import GRID_CELL_SIZE
from sugar import profile
import pygame
@@ -22,6 +30,7 @@ import sugargame.canvas
import load_save
import Spirolaterals
+
class PeterActivity(activity.Activity):
LOWER = 0
UPPER = 400
@@ -105,7 +114,7 @@ class PeterActivity(activity.Activity):
# Note that set_canvas implicitly calls
# read_file when resuming from the Journal.
self.set_canvas(self._pygamecanvas)
- self.game.canvas=self._pygamecanvas
+ self.game.canvas = self._pygamecanvas
gtk.gdk.screen_get_default().connect('size-changed',
self.__configure_cb)
@@ -120,7 +129,7 @@ class PeterActivity(activity.Activity):
''' Screen size has changed '''
logging.debug(self._pygamecanvas.get_allocation())
pygame.display.set_mode((gtk.gdk.screen_width(),
- gtk.gdk.screen_height() - style.GRID_CELL_SIZE),
+ gtk.gdk.screen_height() - GRID_CELL_SIZE),
pygame.RESIZABLE)
self.game.save_pattern()
self.game.g_init()
@@ -130,8 +139,9 @@ class PeterActivity(activity.Activity):
def read_file(self, file_path):
try:
f = open(file_path, 'r')
- except:
- return #****
+ except Exception as e:
+ logging.debug('Error opening %s: %s' % (file_path, e))
+ return
load_save.load(f)
f.close()
@@ -146,7 +156,8 @@ class PeterActivity(activity.Activity):
def _add_speed_slider(self, toolbar):
self._speed_stepper_down = ToolButton('speed-down')
self._speed_stepper_down.set_tooltip(_('Slow down'))
- self._speed_stepper_down.connect('clicked', self._speed_stepper_down_cb)
+ self._speed_stepper_down.connect('clicked',
+ self._speed_stepper_down_cb)
self._speed_stepper_down.show()
self._adjustment = gtk.Adjustment(
@@ -191,4 +202,3 @@ class PeterActivity(activity.Activity):
logging.debug(self._adjustment.value)
self.game.do_slider(self._adjustment.value)
return True
-