Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Ortiz <rafael@activitycentral.com>2011-03-05 02:23:45 (GMT)
committer Rafael Ortiz <rafael@activitycentral.com>2011-03-05 02:23:45 (GMT)
commitee91c66b7b5408a1450202a5d689e6364f0b8d66 (patch)
tree7e37544c451e449c7bb736ca3a39ea9822c5b699
parent81948542d8d240c16bba4c1cd180ffa0f4a40949 (diff)
pep8 fixes for olpcgames
-rw-r--r--Maze.activity/olpcgames/activity.py73
1 files changed, 39 insertions, 34 deletions
diff --git a/Maze.activity/olpcgames/activity.py b/Maze.activity/olpcgames/activity.py
index c12faf7..f8eefc0 100644
--- a/Maze.activity/olpcgames/activity.py
+++ b/Maze.activity/olpcgames/activity.py
@@ -1,7 +1,7 @@
"""Embeds the Canvas widget into a Sugar-specific Activity environment"""
import logging
-logging.root.setLevel( logging.WARN )
-log = logging.getLogger( 'olpcgames.activity' )
+logging.root.setLevel(logging.WARN)
+log = logging.getLogger('olpcgames.activity')
#log.setLevel( logging.INFO )
import pygtk
@@ -16,8 +16,11 @@ from olpcgames import mesh, util
__all__ = ['PyGameActivity']
+
class PyGameActivity(activity.Activity):
- """PyGame-specific activity type, provides boilerplate toolbar, creates canvas
+
+ """PyGame-specific activity type,
+ provides boilerplate toolbar,creates canvas
Subclass Overrides:
@@ -25,7 +28,8 @@ class PyGameActivity(activity.Activity):
format like so:
'package.module:main'
if not function name is provided, "main" is assumed.
- game_handler -- alternate specification via direct reference to a main-loop
+ game_handler -- alternate specification via direct
+ reference to a main-loop
function
game_size -- two-value tuple specifying the size of the display in pixels,
@@ -54,10 +58,11 @@ class PyGameActivity(activity.Activity):
this super-class, with no easy way of overriding without completely rewriting
the __init__ method. We should allow for customising both the UI layout and
the toolbar contents/layout/connection.
-
+
XXX Note that if you change the title of your activity in the toolbar you may
see the same focus issues as we have patched around in the build_toolbar
method. If so, please report them to Mike Fletcher.
+
"""
game_name = None
game_title = 'PyGame Game'
@@ -71,69 +76,69 @@ class PyGameActivity(activity.Activity):
super(PyGameActivity, self).__init__(handle)
self.make_global()
if self.game_size is None:
- width,height = gtk.gdk.screen_width(), gtk.gdk.screen_height()
- log.info( 'Total screen size: %s %s', width,height)
+ width, height = gtk.gdk.screen_width(), gtk.gdk.screen_height()
+ log.info('Total screen size: %s %s', width, height)
# for now just fudge the toolbar size...
- self.game_size = width, height - (1*style.GRID_CELL_SIZE)
+ self.game_size = width, height - (1 * style.GRID_CELL_SIZE)
self.set_title(self.game_title)
toolbar = self.build_toolbar()
- log.debug( 'Toolbar size: %s', toolbar.get_size_request())
+ log.debug('Toolbar size: %s', toolbar.get_size_request())
canvas = self.build_canvas()
- def make_global( self ):
+ def make_global(self):
"""Hack to make olpcgames.ACTIVITY point to us
"""
- import weakref, olpcgames
+ import weakref
+ import olpcgames
assert not olpcgames.ACTIVITY, """Activity.make_global called twice, have you created two Activity instances in a single process?"""
- olpcgames.ACTIVITY = weakref.proxy( self )
+ olpcgames.ACTIVITY = weakref.proxy(self)
- def build_toolbar( self ):
+ def build_toolbar(self):
"""Build our Activity toolbar for the Sugar system
This is a customisation point for those games which want to
provide custom toolbars when running under Sugar.
"""
- OLD_TOOLBAR = False
+ OLD_TOOLBAR = False
try:
- from sugar.graphics.toolbarbox import ToolbarBox, ToolbarButton
- from sugar.activity.widgets import ActivityToolbarButton
+ from sugar.graphics.toolbarbox import ToolbarBox, ToolbarButton
+ from sugar.activity.widgets import ActivityToolbarButton
except ImportError:
OLD_TOOLBAR = True
-
+
if OLD_TOOLBAR:
# toolbar = activity.ActivityToolbar(self)
# toolbar.show()
# self.set_toolbox(toolbar)
- self.toolbox = ActivityToolbox(self)
- self.set_toolbox(self.toolbox)
- self.toolbox.show()
- self.set_toolbox(self.toolbox)
+ self.toolbox = ActivityToolbox(self)
+ self.set_toolbox(self.toolbox)
+ self.toolbox.show()
+ self.set_toolbox(self.toolbox)
else:
- toolbar_box = ToolbarBox()
- self.activity_button = ActivityToolbarButton(self)
- toolbar_box.toolbar.insert(self.activity_button, 0)
- self.set_toolbar_box(toolbar_box)
+ toolbar_box = ToolbarBox()
+ self.activity_button = ActivityToolbarButton(self)
+ toolbar_box.toolbar.insert(self.activity_button, 0)
+ self.set_toolbar_box(toolbar_box)
-
def shared_cb(*args, **kwargs):
- log.info( 'shared: %s, %s', args, kwargs )
+ log.info('shared: %s, %s', args, kwargs)
try:
mesh.activity_shared(self)
except Exception, err:
- log.error( """Failure signaling activity sharing to mesh module: %s""", util.get_traceback(err) )
+ log.error("""Failure signaling activity sharing to mesh module: %s""", util.get_traceback(err))
else:
- log.info( 'mesh activity shared message sent, trying to grab focus' )
+ log.info('mesh activity shared message sent, trying to grab focus')
try:
self._pgc.grab_focus()
except Exception, err:
- log.warn( 'Focus failed: %s', err )
+ log.warn('Focus failed: %s', err)
else:
- log.info( 'asserting focus' )
+ log.info('asserting focus')
assert self._pgc.is_focus(), """Did not successfully set pygame canvas focus"""
- log.info( 'callback finished' )
+ log.info('callback finished')
def joined_cb(*args, **kwargs):
- log.info( 'joined: %s, %s', args, kwargs )
+ log.info('joined: %s, %s', args, kwargs)
mesh.activity_joined(self)
self._pgc.grab_focus()
self.connect("shared", shared_cb)
@@ -148,7 +153,7 @@ class PyGameActivity(activity.Activity):
return toolbar
PYGAME_CANVAS_CLASS = PyGameCanvas
- def build_canvas( self ):
+ def build_canvas(self):
"""Construct the PyGame or PyGameCairo canvas for drawing"""
assert self.game_handler or self.game_name, 'You must specify a game_handler or game_name on your Activity (%r)'%(
self.game_handler or self.game_name