views:

38

answers:

2

In my Python2_6/include directory is a folder with pygame headers. I assumed that my python C module can access pygame stuff directly in C. Is this the case? How do I integrate a C module that wants to use pygame, with a python script using pygame? Right now my brain sees:

pygame <-- MyCModule <-- MyScript --> pygame

ie. Two pygame instances. So is it possible to integrate them so that my module and my app use the same instance? Why are there pygame headers in my python include directory, can I use those somehow, for direct access?

Thanks for any help.

A: 

I assumed that my python C module can access pygame stuff directly in C. Is this the case?

No, that stuff is most likely just there because it was necessary to compile the pygame Python extension.

I don't understand what you mean when you say you see 2 pygame instances. There are as many instances as you create, no more, no less. If you have script that creates pygame objects, and your extension also creates pygame objects, then of course you will have 2 sets of objects. As the writer of the application you need to decide which part of it will have responsibility for interfacing with pygame. If the other part requires access to those pygame objects, then you pass them in as arguments.

Kylotan
A: 

See this question. The code given in the accepted answer checks whether Pygame was already loaded, so you won't end up with two sets of Pygame stuff.

Also, those headers aren't for custom C modules. They're probably required for some SDL stuff.

Javier Badia