adonthell-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Adonthell-devel] New structure status, thoughts, and problems


From: Alexandre Courbot
Subject: Re: [Adonthell-devel] New structure status, thoughts, and problems
Date: 21 Mar 2003 14:15:13 +0100

> Yeah, that would be nice. Seeing the code might also help with the
> callback stuff. Right now I wouldn't have any idea how it could be
> handled.

You can get it there:
http://www.gnurou.org/adonthell-stuff/adonthell-0.4dev1.tar.gz

The few that is inside should be well documented. Configure and install
it like the last one (I advice you use --prefix and set PYTHONPATH
correctly to avoid messing up your system). Then the following Python
program should work:

#########
from adonthell import gfx, input, python

def mycallback():
    print "Oki doki"

gfx.init("sdl")
input.init("sdl")

gfx.screen.set_video_mode(640, 480)

callback = python.callback(mycallback, ())

listener = input.listener()
listener.connect_function(input.event.KEYBOARD_EVENT, callback)

input.manager.add(listener)

while 1:
    input.manager.update()
#####

It will call the callback function every time a function is pushed. The
problem is that right now the callback doesn't take any argument, while
it should take the event that has been triggered. I just can't think of
a clean and generic way to make callbacks with a parameterized number of
arguments (and types!) that would both work on C++ and Python. The code
of interest is in base/callback.h and python/callback.h. I'm short of
time right now, maybe I can be more precise this evening if you have
trouble getting where the problem lies.

Have fun! :)
Alex.
-- 
http://www.gnurou.org





reply via email to

[Prev in Thread] Current Thread [Next in Thread]