11/04/2008

Ant Tweak Bar ctypes module

For every 3d project iv made with python ive always written a way to use Ant Tweak Bar so I thought for historical reasons I should again for use with pyglet ( and pyglons ). So..

atb-ctypes is a ctypes wrapper around Ant Tweak Bar. It includes a pyglet event handler that can easily be pushed onto the event stack. It is of course perfectly possible to use atb-ctypes with any other windowing/event library, it does not depend on pyglet.

A very minimal sample:

import pyglet
from pyglet.gl import *

import atb
from atb.pyglet_handler import ATBEventHandler

window = pyglet.window.Window()

@window.event
def on_close():
    pyglet.app.exit()

atbhandler = ATBEventHandler(window)

if __name__ == '__main__':
    atb.init()

    for x in range(2):
        bar = atb.Bar('my bar %d' % x)
        myVar = c_float()
        COLOR4F = c_float * 4
        myColor = COLOR4F()
        bar.add_var("some float", myVar)
        bar.add_var("some color", myColor)

    def say_hello(*args):
        print args, "hello"

    bar = atb.Bar('buttons')
    bar.add_button("my button", say_hello)

    pyglet.app.run()

The code is in the pyglons googlecode repo now.

Now I have to go socialize... Its friday!! :]

No comments: