Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to Python 3 #6

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 1 addition & 1 deletion activity/activity.info
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = Panorama
activity_version = 9
bundle_id = org.laptop.PanoramaActivity
exec = sugar-activity activity.PanoramaActivity
exec = sugar-activity3 activity.PanoramaActivity
icon = activity-panorama
show_launcher = yes
license = GPLv3+
Expand Down
2 changes: 1 addition & 1 deletion pano.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from pygame.locals import *
from pygame import camera
except ImportError:
print 'Error in import Pygame. This activity requires Pygame 1.9'
print('Error in import Pygame. This activity requires Pygame 1.9')


class PanoCapture():
Expand Down
2 changes: 1 addition & 1 deletion 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
from . import event

CANVAS = None

Expand Down
8 changes: 4 additions & 4 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,10 +168,10 @@ 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)
evt = pygame.event.Event(type, key=keycode, str=ukey, mod=mod)
self._post(evt)

return True
Expand Down Expand Up @@ -248,7 +248,7 @@ def _get_mouse_pos(self):
def _post(self, evt):
try:
pygame.event.post(evt)
except pygame.error, e:
except pygame.error as e:
if str(e) == 'video system not initialized':
pass
elif str(e) == 'Event queue full':
Expand Down