From 9298af0715e20f0ab9bb3a5f5c8484512c113a39 Mon Sep 17 00:00:00 2001 From: Aniket21mathur Date: Fri, 24 May 2019 12:58:18 +0530 Subject: [PATCH] Port to Python 3. --- activity/activity.info | 2 +- page.py | 6 +++--- utils/aplay.py | 2 +- utils/sprites.py | 10 +++++----- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/activity/activity.info b/activity/activity.info index 5018df1..5c54f9d 100644 --- a/activity/activity.info +++ b/activity/activity.info @@ -3,7 +3,7 @@ name = AEIOU activity_version = 6 license = GPLv3 bundle_id = org.sugarlabs.AEIOU.NI -exec = sugar-activity aeiou.AEIOU +exec = sugar-activity3 aeiou.AEIOU icon = activity-aeiou show_launcher = yes summary = learn the vowel sounds diff --git a/page.py b/page.py index b4b6c7b..f629d84 100644 --- a/page.py +++ b/page.py @@ -246,7 +246,7 @@ def _play_target_sound(self): def _button_press_cb(self, win, event): ''' Either a card or list entry was pressed. ''' win.grab_focus() - x, y = map(int, event.get_coords()) + x, y = list(map(int, event.get_coords())) spr = self._sprites.find_sprite((x, y)) self._press = spr @@ -257,7 +257,7 @@ def _button_release_cb(self, win, event): ''' Play a sound or video or jump to a card as indexed in the list. ''' win.grab_focus() - x, y = map(int, event.get_coords()) + x, y = list(map(int, event.get_coords())) spr = self._sprites.find_sprite((x, y)) if spr is None: return @@ -377,7 +377,7 @@ def _clear_all(self): def svg_str_to_pixbuf(svg_string): ''' Load pixbuf from SVG string. ''' pl = GdkPixbuf.PixbufLoader.new_with_type('svg') - pl.write(svg_string) + pl.write(bytes(svg_string.encode())) pl.close() return pl.get_pixbuf() diff --git a/utils/aplay.py b/utils/aplay.py index c653939..781ac3a 100644 --- a/utils/aplay.py +++ b/utils/aplay.py @@ -16,7 +16,7 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import logging -from Queue import Queue +from queue import Queue import gi gi.require_version('Gst', '1.0') from gi.repository import Gst diff --git a/utils/sprites.py b/utils/sprites.py index e33cefb..266f613 100644 --- a/utils/sprites.py +++ b/utils/sprites.py @@ -142,7 +142,7 @@ def redraw_sprites(self, area=None, cr=None): else: self.cr = cr if cr is None: - print 'sprites.redraw_sprites: no Cairo context' + print('sprites.redraw_sprites: no Cairo context') return for spr in self.list: if area == None: @@ -251,7 +251,7 @@ def set_layer(self, layer=None): def set_label(self, new_label, i=0): ''' Set the label drawn on the sprite ''' self._extend_labels_array(i) - if type(new_label) is str or type(new_label) is unicode: + if type(new_label) is str or type(new_label) is str: # pango doesn't like nulls self.labels[i] = new_label.replace("\0", " ") else: @@ -329,7 +329,7 @@ def draw(self, cr=None): if cr is None: cr = self._sprites.cr if cr is None: - print 'sprite.draw: no Cairo context.' + print('sprite.draw: no Cairo context.') return for i, img in enumerate(self.images): if isinstance(img, GdkPixbuf.Pixbuf): @@ -350,7 +350,7 @@ def draw(self, cr=None): self.rect[3]) cr.fill() else: - print 'sprite.draw: source not a pixbuf (%s)' % (type(img)) + print('sprite.draw: source not a pixbuf (%s)' % (type(img))) if len(self.labels) > 0: self.draw_label(cr) @@ -462,5 +462,5 @@ def get_pixel(self, pos, i=0): else: return(-1, -1, -1, -1) except IndexError: - print "Index Error: %d %d" % (len(array), offset) + print("Index Error: %d %d" % (len(array), offset)) return(-1, -1, -1, -1)