Skip to content

Commit

Permalink
Port to Python3
Browse files Browse the repository at this point in the history
  • Loading branch information
Pro-Panda committed May 21, 2018
1 parent 015d607 commit 02a2727
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions CowBulls.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ def change_level(self, level):
self.compare_list = []
self.score = 0
self.parent.update_score(self.score)
self.next_button.set_sensitive(False)

def nextRound(self):
g.screen.fill((0, 0, 0))
Expand Down
4 changes: 2 additions & 2 deletions activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import CowBulls


class CowBullsActivtiy(activity.Activity):
class CowBullsActivity(activity.Activity):

def __init__(self, handle):
activity.Activity.__init__(self, handle)
Expand Down Expand Up @@ -153,7 +153,7 @@ def update_score(self, score):
def _svg_str_to_pixbuf(self, svg_string):
''' Load pixbuf from SVG string '''
pl = GdkPixbuf.PixbufLoader.new_with_type('svg')
pl.write(svg_string)
pl.write(svg_string.encode())
pl.close()
pixbuf = pl.get_pixbuf()
return pixbuf
Expand Down
2 changes: 1 addition & 1 deletion activity/activity.info
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ host_version = 1
bundle_id = org.laptop.community.CowBulls
icon = activity
show_launcher = yes
exec = sugar-activity activity.CowBullsActivtiy
exec = sugar-activity3 activity.CowBullsActivity
license = GPLv3+
category = maths game
summary = "CowBulls Math Puzzle game"
Expand Down
4 changes: 2 additions & 2 deletions sugargame/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from gi.repository import GLib
from sugar3.activity.activity import PREVIEW_SIZE
import pygame
import event
import sugargame.event as event

CANVAS = None

Expand Down Expand Up @@ -78,7 +78,7 @@ def get_preview(self):
_surface = pygame.transform.scale(self._screen, (width, height))
pygame.image.save(_surface, _file_path)

f = open(_file_path, 'r')
f = open(_file_path, 'rb')
preview = f.read()
f.close()
os.remove(_file_path)
Expand Down
4 changes: 2 additions & 2 deletions sugargame/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def _keyup_cb(self, widget, event):

def _keymods(self):
mod = 0
for key_val, mod_val in self.mod_map.iteritems():
for key_val, mod_val in self.mod_map.items():
mod |= self.__keystate[key_val] and mod_val
return mod

Expand Down Expand Up @@ -168,7 +168,7 @@ def _keyevent(self, widget, event, type):
self.__keystate[keycode] = type == pygame.KEYDOWN
if type == pygame.KEYUP:
mod = self._keymods()
ukey = unichr(Gdk.keyval_to_unicode(event.keyval))
ukey = chr(Gdk.keyval_to_unicode(event.keyval))
if ukey == '\000':
ukey = ''
evt = pygame.event.Event(type, key=keycode, unicode=ukey, mod=mod)
Expand Down
4 changes: 2 additions & 2 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ def get_num(level):
num = [0]
while num[0] == 0:
if level == 3:
num = random.sample(range(0, 10), 3)
num = random.sample(list(range(0, 10)), 3)
else:
num = [random.choice(range(0, 10)) for x in range(level)]
num = [random.choice(list(range(0, 10))) for x in range(level)]
return num


Expand Down

0 comments on commit 02a2727

Please sign in to comment.