[pygame] Re: Extending Surface Class

2009-07-25 Thread ERName
Oh thanks for the translation :)

Well, the whole point was to make the process automatic, and my
program not even know that the class was different, so a wrapper
attribute kind of defeats the purpose. It's alright, though, I can
just live with the standard Surface __str__(). No biggie.

Thanks for the help, though, guys!


[pygame] Re: Extending Surface Class

2009-07-25 Thread ERName
Well, I appreciate your reply, but I don't really understand what you
mean by "wrapper"... and this mysterious _sruf attribute?

The part about being a C object I understand, though, and I was afraid
of that. If there's not any easy way of doing this, I can just live
with the default __str__(), I guess.


[pygame] Extending Surface Class

2009-07-25 Thread ERName
Is it possible to extend the surface class? Every time I do the
surface ends up dieing somehow right after it is created... I may just
be doing it in the wrong way, though. The main point is to override
the __str__() method, so if you know another way besides extending
pygame.Surface, I'd be happy to hear it.


class ExtendedSurface(pygame.Surface):

def __init__(self, surface, string):
pygame.Surface.__init__(surface, surface.get_size()) #The docs
say to include a size, etc. but that just gives me "too many values to
unpack" errors.
self.string = string

def __str__(self):
return self.string



Thanks!