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

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



----- Original Message -----
From: "Pete Shinners" <pete@shinners.org>
To: <pygame-users@seul.org>
Sent: Friday, July 11, 2003 6:11 PM
Subject: Re: [pygame] Newbie - trouble with inheritance in pygame


> Psymaster wrote:
> > 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
>
> the problem is Font is a C extension type, which by default aren't
> inheritable from. this isn't too hard to update, but for now i still
> want to maintain compatability with old python releases.
>
> this just means there's a bunch of #if blocks all over getting
functions
> and structures all in the right place. i did this for Rect and
Surface
> because i figured it would be the most useful. it was a bit of a
pain so
> i figured i'd wait and see how that went.
>
> there are still a few types in pygame that cannot be subclassed,
Font is
> surely one of them others are the different devices like Joystick
and
> CD. probably the only ones that could be candidates for subclassing
> might be Font and Sound.
>
> of course, now that i know what to do, it's not too rough to update
> these classes. if i have time next week i'll slip this in for the
next
> pygame release :]
>
>

Sounds great, Pete!