Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions SliderPuzzleActivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import logging
import os
import sys
import md5
import hashlib

logger = logging.getLogger('sliderpuzzle-activity')

Expand All @@ -48,11 +48,11 @@
# game tube
import zlib
import time
from cStringIO import StringIO
from io import StringIO

from dbus import Interface, DBusException
from dbus.service import method, signal
from dbus.gobject_service import ExportedGObject
from dbus.service import Object as ExportedGObject

from mamamedia_modules import GAME_IDLE, GAME_STARTED, GAME_FINISHED, GAME_QUIT
import logging
Expand Down
10 changes: 6 additions & 4 deletions SliderPuzzleUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# If you find this activity useful or end up using parts of it in one of your
# own creations we would love to hear from you at [email protected] !
#
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, GObject, Pango, Gdk

from mamamedia_modules import utils
Expand All @@ -38,7 +40,7 @@
from SliderPuzzleWidget import SliderPuzzleWidget
from time import time
import os
import md5
import hashlib
from sugar3.activity.activity import get_bundle_path
from sugar3 import mime
from sugar3.graphics.objectchooser import ObjectChooser
Expand Down Expand Up @@ -491,11 +493,11 @@ def _thaw(self, obj):
if not obj[1]['image']:
return

if not obj[1].has_key('image'):
if 'image' not in obj[1]:
self.game.load_image(self.pbb)
self.set_nr_pieces(None, obj[2])
logging.debug(obj[1].keys())
wimg = obj[1].has_key('image')
logging.debug(list(obj[1].keys()))
wimg = 'image' in obj[1]
self.game._thaw(obj[1])
if wimg:
logging.debug("Forcing thumb image from the one in game")
Expand Down
18 changes: 10 additions & 8 deletions SliderPuzzleWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,22 @@
# If you find this activity useful or end up using parts of it in one of your
# own creations we would love to hear from you at [email protected] !
#

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, GObject, Pango, GdkPixbuf, Gdk
import md5
import hashlib
import logging
import tempfile
from mamamedia_modules import utils

#from utils import load_image, calculate_matrix, debug, SliderCreator, trace

from types import TupleType, ListType
TupleType = tuple
ListType = list
from random import random
from time import time
from math import sqrt
from cStringIO import StringIO
from io import StringIO
import os

###
Expand Down Expand Up @@ -113,7 +115,7 @@ def prepare_stringed(self, rows, cols):
# if c > 0 and r > 0:
# pm.draw_line(gc, px, 0, px, self.height-1)
# pm.draw_line(gc, 0, py, self.width-1, py)
pangolayout.set_text(str(item.next()))
pangolayout.set_text(str(next(item)))
pe = pangolayout.get_pixel_extents()
pe = pe[1][2] / 2, pe[1][3] / 2
pm.draw_layout(gc, px + (sw / 2) -
Expand Down Expand Up @@ -194,7 +196,7 @@ def __init__(self, pieces=9, move_cb=None):

def reset(self, pieces=9):
self.pieces, self.rowsize, self.colsize = calculate_matrix(pieces)
pieces_map = range(1, self.pieces + 1)
pieces_map = list(range(1, self.pieces + 1))
self.pieces_map = []
for i in range(self.rowsize):
self.pieces_map.append(
Expand Down Expand Up @@ -399,7 +401,7 @@ def _freeze(self):
'pieces_map': self.pieces_map, 'hole_pos_freeze': self.hole_pos._freeze()}

def _thaw(self, obj):
for k in obj.keys():
for k in list(obj.keys()):
if hasattr(self, k):
setattr(self, k, obj[k])
self.hole_pos._thaw(obj.get('hole_pos_freeze', None))
Expand Down Expand Up @@ -605,7 +607,7 @@ def _thaw(self, obj):
""" retrieves a frozen status from a python object, as per _freeze """
logging.debug(obj['jumbler'])
self.jumbler._thaw(obj['jumbler'])
if obj.has_key('image') and obj['image'] is not None:
if 'image' in obj and obj['image'] is not None:
self.set_image_from_str(obj['image'])
del obj['image']
self.full_refresh()
Expand Down
2 changes: 1 addition & 1 deletion activity/activity.info
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[Activity]
name = Slider Puzzle
bundle_id = org.worldwideworkshop.olpc.SliderPuzzle
exec = sugar-activity SliderPuzzleActivity.SliderPuzzleActivity
exec = sugar-activity3 SliderPuzzleActivity.SliderPuzzleActivity
icon = activity-sliderpuzzle
activity_version = 10
show_launcher = yes
Expand Down
2 changes: 2 additions & 0 deletions mamamedia_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import os
import sys
import gi
gi.require_version('Gtk', '3.0')

cwd = os.path.split(__file__)[0]

Expand Down
16 changes: 8 additions & 8 deletions mmm_modules/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from borderframe import *
from timer import *
from image_category import *
from i18n import *
from .borderframe import *
from .timer import *
from .image_category import *
from .i18n import *
#from notebook_reader import *
from buddy_panel import *
from tube_helper import *
import utils
import json
from .buddy_panel import *
from .tube_helper import *
from .utils import *
from . import json
3 changes: 2 additions & 1 deletion mmm_modules/borderframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
# If you find this activity useful or end up using parts of it in one of your
# own creations we would love to hear from you at [email protected] !
#

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, GObject, Gdk

BORDER_LEFT = 1
Expand Down
2 changes: 1 addition & 1 deletion mmm_modules/buddy_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import logging

from tube_helper import GAME_IDLE, GAME_STARTED, GAME_FINISHED, GAME_QUIT
from .tube_helper import GAME_IDLE, GAME_STARTED, GAME_FINISHED, GAME_QUIT

#from sugar.graphics.icon import CanvasIcon

Expand Down
13 changes: 7 additions & 6 deletions mmm_modules/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
import os
import gettext
import locale

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import GObject

Expand Down Expand Up @@ -166,11 +167,11 @@ def install(self, *args):

def gather_other_translations():
from glob import glob
lessons = filter(lambda x: os.path.isdir(x), glob('lessons/*'))
lessons = map(lambda x: os.path.basename(x), lessons)
lessons = map(lambda x: x[0].isdigit() and x[1:] or x, lessons)
images = filter(lambda x: os.path.isdir(x), glob('images/*'))
images = map(lambda x: os.path.basename(x), images)
lessons = [x for x in glob('lessons/*') if os.path.isdir(x)]
lessons = [os.path.basename(x) for x in lessons]
lessons = [x[0].isdigit() and x[1:] or x for x in lessons]
images = [x for x in glob('images/*') if os.path.isdir(x)]
images = [os.path.basename(x) for x in images]
f = file('i18n_misc_strings.py', 'w')
for e in images + lessons:
f.write('_("%s")\n' % e)
Expand Down
6 changes: 3 additions & 3 deletions mmm_modules/image_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
import os
from glob import glob
import logging
import md5
import hashlib
from sugar3.activity.activity import Activity, get_bundle_path
from utils import load_image, resize_image, RESIZE_CUT
from borderframe import BorderFrame
from .utils import load_image, resize_image, RESIZE_CUT
from .borderframe import BorderFrame
from gettext import gettext as _

THUMB_SIZE = 48
Expand Down
Loading