[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Newbie - trouble with inheritance in pygame



----- Original Message -----
From: "Lee Harr" <missive@hotmail.com>
To: <pygame-users@seul.org>
Sent: Friday, July 11, 2003 4:11 PM
Subject: Re: [pygame] Newbie - trouble with inheritance in pygame


> >Sorry if it's been asked before, but why this doesn't work:
> >
> >class my_font(pygame.font.Font):
> >     pass
> >
> >while this does:
> >
> >class my_sprite(pygame.sprite.Sprite):
> >     pass
> >
> >the first gives a TypeError
> >
>
>
> One issue is that pygame.font is an extension module (that is, it
> is coded in C and loaded from the shared object .so  or .dll file)
> whereas pygame.sprite is a regular python module.
>
> I seem to recall that pygame.Rect used to be the same way, and
> there was a UserRect that could be subclassed....  Hmm.  Maybe
> Font just needs to be rewritten as a new-style class?
>
> Sorry, hopefully someone more knowledgeable will answer also  :o)
>
Oh, thanks, I thought I was doing something wrong, since it is by
implementation I'll create an instance straight from the base class.