RE: [Pythoncard-users] PythonCard + Pygame
by Kevin Altis other posts by this author
Feb 14 2004 7:47PM messages near this date
[Pythoncard-users] PythonCard + Pygame
|
[Pythoncard-users] error on restoring minimized application
From: Brian Debuire
Hi,
I wonder if there is a way of using pythonCard and Pygame in the same app.
What i am trying to do is a kind of math functions drawer, but i just know
how to draw in pygame.
If PythonCard does not have this option of "graphication", i think it should
have.
Thanks and write soon. ;-)
Brian
---
The answer is yes and no. You can mix PyGame and PythonCard, but perhaps not
in the way you want. There are some platform-specific issues in addition to
the base issue of having two event loops which is always complicated. The
way PyGame initializes its modules is problematic as well since you need to
set an environment variable with the HWND for a wxPython window that PyGame
should use to draw in, but that needs to occur before you import PyGame. I
haven't experimented with this since last year when I was trying to use
PyGame to play MP3s and MPEG movies so things may have changed since then.
The interactions are wxPython issues as much as PythonCard, so your best bet
is to search the archives and look at some of the discussions and examples.
This issue comes up fairly regularly, but we don't have a simple set of
examples.
http://aspn.activestate.com/ASPN/search?query=pygame&type=Archive_PythonCard
_list
http://aspn.activestate.com/ASPN/search?query=PyGame&type=Archive_wxPython-u
sers_list
http://aspn.activestate.com/ASPN/search?query=wxpython&type=Archive_pygame-u
sers_list
If having a separate PyGame window is acceptable, then using threads you can
probably get the effect you want. Remember to use the Python Queue module or
use wxPostEvent/wxCallAfter from the PyGame thread to avoid GUI thread
problems. If you just want to use PyGame modules that don't involve a GUI
event loop or don't conflict with wxPython then mixing the two is easy. The
CD player thread illustrates on possibility.
http://aspn.activestate.com/ASPN/Mail/Message/1237679
Finally, PythonCard contains quite a it of drawing capabilities itself and
that may also solve your problem, but I would need more details on your
program to know for sure.
ka
Attachments:
unknown1
Thread:
Brian Debuire
Kevin Altis
|