472,146 Members | 1,470 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,146 software developers and data experts.

Multiple Windows in Pygame, using true concurrency in python via Kamaelia

Hi,
Just thought some people may be interested to hear that I've recently been
looking at adding true concurrency into Kamaelia, by using Paul Boddie's
pprocess as the core mechanism to allow us to run multiple Kamaelia systems
in the same app. (Since we have thread based, and co-operative generator
based components, process based is the next logical step)

[1] http://kamaelia.sourceforge.net/Home
[2] http://pypi.python.org/pypi/pprocess

Anyhow, first proof of concept is to take a _relatively_ non-trivial app and
a library hostile to being run in a single process and run it across
multiple processes trivially. (I can't test multicpu since I don't have a
multicpu machine, but this should work fine with a modern OS)

So the app I've chosen is a simple pygame based drawing/doodling app, and to
get it to launch 8 pygame windows from 1 app. Since neither SDL nor pygame
directly support this it struck me as not just a visible proof of concept,
but a useful one too (since pygame rocks! :-)

Anyhow, I've written up the code here and posted a screenshot here:
http://yeoldeclue.com/cgi-bin/blog/b...eid=1196129474

You'll note 8 pygame windows ... :-)

The original base test is here:
http://yeoldeclue.com/cgi-bin/blog/b...eid=1196029230

For those curious who don't like clicking on links, the code needed to allow
the 8 pygame windows looks like this:

class SecondProcessBasedComponent(SimplestProcessCompone nt):
def main(self):
from Kamaelia.UI.Pygame.Display import PygameDisplay
from Kamaelia.UI.Pygame.MagnaDoodle import MagnaDoodle

X=PygameDisplay(width=200,height=200).activate()
PygameDisplay.setDisplayService(X)
MagnaDoodle().run()
yield 1

exchange = SecondProcessBasedComponent().activate()
R = []
for _ in xrange(7):
R.append(SecondProcessBasedComponent().activate())

So far, so good :-)

Incidentally, yes the project is alive and well, but a resource crunch
at work means I'm working on this only on my own time at the mo, which
means things like releases are having a longer cycle between them than
I'd like. Some recent developments include a greylisting proxy server,
a ER modelling tool and a (very) simple pygame based logo like tool for
teaching programming to small children. The webserver is aiming for WSGI
compliance, and the project also had a small number of students working
over the summer, assisting with some useful things like AIM/IRC integration,
the ability to use Kamaelia systems in non-Kamaelia based scripts/systems,
and looking at a sub-component model. (ie non-concurrent systems)
Michael.
--
http://yeoldeclue.com/blog
http://kamaelia.sourceforge.net/Home

Dec 2 '07 #1
0 1676

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by john | last post: by
5 posts views Thread by Andrea Griffini | last post: by
5 posts views Thread by Andr? Roberge | last post: by
10 posts views Thread by Eric S. Johansson | last post: by
9 posts views Thread by corey.coughlin | last post: by
1 post views Thread by liuliuliu | last post: by
4 posts views Thread by jedi200581 | last post: by
6 posts views Thread by Kay Schluehr | last post: by
tharden3
2 posts views Thread by tharden3 | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.