diff --git a/pygwin/__init__.py b/pygwin/__init__.py index 58cbcde..0c6525c 100644 --- a/pygwin/__init__.py +++ b/pygwin/__init__.py @@ -6,7 +6,7 @@ from pygwin.rect import rect import pygwin.image as image import pygwin.mixer as mixer from pygame.locals import * -from pygwin.font import * +import pygwin.font as font from pygwin._win import * from pygwin._pg import pg import pygwin.ui as ui diff --git a/pygwin/image.py b/pygwin/image.py index be2aa6a..b61d345 100644 --- a/pygwin/image.py +++ b/pygwin/image.py @@ -16,8 +16,10 @@ def load(path): surfs.append(surf) return surfs else: - surf = _surface(_im.open(path).size) - surf.blit(_pg.image.load(path),(0,0)) + im = _im.open(path.encode('utf8').decode('utf8')) + image = _pg.image.fromstring(im.tobytes(),im.size,im.mode) + surf = _surface(im.size) + surf.blit(image,(0,0)) return surf def save(surface, dest): @@ -27,15 +29,15 @@ def save(surface, dest): orig = surface._orig _pg.image.save_extended(orig, dest) -def toString(surface): +def toBytes(surface): try: orig = surface._surface_orig except: orig = surface._orig - return _bz2.compress(_p.dumps([_pg.image.tostring(orig,"RGBA"),list(surface.size)])).decode('latin1') + return _bz2.compress(_p.dumps([_pg.image.tostring(orig,"RGBA"),list(surface.size)])) -def fromString(string): - string = _p.loads(_bz2.decompress(string.encode('latin1'))) +def fromBytes(bytes): + string = _p.loads(_bz2.decompress(bytes)) surf = _pg.image.fromstring(string[0],tuple(string[1]),"RGBA") surface = _surface(tuple(string[1])) surface.blit(surf,(0,0)) diff --git a/pygwin/ui.py b/pygwin/ui.py index 627e178..f404357 100644 --- a/pygwin/ui.py +++ b/pygwin/ui.py @@ -242,6 +242,8 @@ class loadingBar(widget): self.loaded = self.length def reset(self): self.loaded = 0 + def get(self): + return self.loaded def draw(self, win, pos): self.surface = _s((self.width,self.height)) self.surface.fill(self.borderColor)