diff options
author | Rafael Ortiz <rafael@activitycentral.com> | 2012-03-29 20:17:43 (GMT) |
---|---|---|
committer | Rafael Ortiz <rafael@activitycentral.com> | 2012-03-29 20:17:43 (GMT) |
commit | 8fb41022b107f77375365293160e0cd67008d76c (patch) | |
tree | 03de04693980b633d0856f1d704468f8d3df8a46 | |
parent | 840c7b75c705758c6b78acd0a76258ca775088a8 (diff) |
various style fixes
-rw-r--r-- | olpcgames/canvas.py | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/olpcgames/canvas.py b/olpcgames/canvas.py index 2583827..20d8cda 100644 --- a/olpcgames/canvas.py +++ b/olpcgames/canvas.py @@ -2,7 +2,7 @@ import os import sys import logging -log = logging.getLogger( 'olpcgames.canvas' ) +log = logging.getLogger('olpcgames.canvas') ##log.setLevel( logging.DEBUG ) import threading from pprint import pprint @@ -13,8 +13,8 @@ import gtk import gobject import pygame -from olpcgames import gtkEvent, util - +from olpcgames import gtkEvent +from olpcgames import util __all__ = ['PygameCanvas'] class PygameCanvas(gtk.Layout): @@ -26,6 +26,7 @@ class PygameCanvas(gtk.Layout): window pointer, it draws to that X-level window in order to produce output. """ mod_name = None + def __init__(self, width, height): """Initializes the Canvas Object @@ -38,8 +39,8 @@ class PygameCanvas(gtk.Layout): sub-class, e.g. to get size from the host window, or something similar. """ # Build the main widget - log.info( 'Creating the pygame canvas' ) - super(PygameCanvas,self).__init__() + log.info('Creating the pygame canvas') + super(PygameCanvas, self).__init__() self.set_flags(gtk.CAN_FOCUS) # Build the sub-widgets @@ -79,7 +80,7 @@ class PygameCanvas(gtk.Layout): Causes the gtkEvent.Translator to "hook" Pygame Creates and starts secondary thread for Game/Pygame event processing. """ - log.info( 'Connecting the pygame canvas' ) + log.info('Connecting the pygame canvas') # Setup the embedding os.environ['SDL_WINDOWID'] = str(self._socket.get_id()) #print 'Socket ID=%s'%os.environ['SDL_WINDOWID'] @@ -102,13 +103,14 @@ class PygameCanvas(gtk.Layout): def _start(self, fn): """The method that actually runs in the background thread""" - log.info( 'Staring the mainloop' ) + log.info('Staring the mainloop') import olpcgames olpcgames.widget = olpcgames.WIDGET = self try: - import sugar.activity.activity,os + import sugar.activity.activity + import os except ImportError, err: - log.info( """Running outside Sugar""" ) + log.info("""Running outside Sugar""") else: try: os.chdir(sugar.activity.activity.get_bundle_path()) @@ -118,7 +120,7 @@ class PygameCanvas(gtk.Layout): try: try: try: - log.info( '''Running mainloop: %s''', fn ) + log.info('''Running mainloop: %s''', fn) fn() except Exception, err: log.error( @@ -127,13 +129,13 @@ class PygameCanvas(gtk.Layout): ) raise else: - log.info( "Mainloop exited" ) + log.info("Mainloop exited") finally: - log.debug( "Clearing any pending events" ) + log.debug("Clearing any pending events") from olpcgames import eventwrap eventwrap.clear() finally: - log.info( 'Main function finished, calling main_quit' ) + log.info('Main function finished, calling main_quit') gtk.main_quit() source_object_id = None @@ -168,4 +170,4 @@ class PygameCanvas(gtk.Layout): from sugar.activity.activity import show_object_in_journal show_object_in_journal(object_id) except ImportError: - pass # no love from sugar. + pass # no love from sugar. |