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

Fixes issue #19 Port to Python 3 #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion SearchActivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

from json import load as jload
from json import dump as jdump
from StringIO import StringIO
from io import StringIO

from game import Game

Expand Down
2 changes: 1 addition & 1 deletion game.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def _floodfill(self, old_type, spr):

def _button_press_cb(self, win, event):
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:
Expand Down
12 changes: 6 additions & 6 deletions sprites.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 is None:
Expand Down Expand Up @@ -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 isinstance(new_label, str) or isinstance(new_label, unicode):
if isinstance(new_label, str) or isinstance(new_label, str):
# pango doesn't like nulls
self.labels[i] = new_label.replace("\0", " ")
else:
Expand Down Expand Up @@ -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):
Expand All @@ -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)

Expand Down Expand Up @@ -460,7 +460,7 @@ def get_pixel(self, pos, i=0):
if array is not None:
offset = (y * self.images[i].get_width() + x) * 4
if offset < 0 or offset > len(array) - 4:
print "Index Error: %d %d" % (len(array), offset)
print("Index Error: %d %d" % (len(array), offset))
return(-1, -1, -1, -1)
else:
offset = (y * self.images[i].get_width() + x) * 4
Expand All @@ -471,5 +471,5 @@ def get_pixel(self, pos, i=0):
else:
return(r, g, b, a)
else:
print "Array is none"
print("Array is none")
return(-1, -1, -1, -1)
2 changes: 1 addition & 1 deletion utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# Foundation, 51 Franklin Street, Suite 500 Boston, MA 02110-1335 USA


from StringIO import StringIO
from io import StringIO
try:
OLD_SUGAR_SYSTEM = False
import json
Expand Down