Help with python bindings for 007?

Hi

I’ve been using a python binding of v0062 for OS X that I inherited as part of a software project at work. I’m looking to update to the latest build of OF, and in the process make some small changes to the source code (to get around some issues passing refs & pointers to python). Unfortunately I have absolutely no experience with SWIG, or even C++ really (I’m coming from java & python). Is anyone still working with python bindings? If so, I could use some help understanding SWIG & the process of creating these.

OF runs incredibly well in python & no other python libraries compare when it comes to doing interactive work. I’d love to help build a community around this, but I’m having a hell of a time getting started with it. SWIG is totally over my head.

Any help: greatly appreciated.

Thanks
-Kyle

huh, that sounds interesting, and like a good reason to learn python, theoretically.
Do you have these bindings online somwhere (github)? if they worked in 0062, maybe it’s not that difficult to adapt to the current version. (btw, new release 0071 coming shortly, so don’t run too fast adapting to 0070 :D)

There are some bindings floating around on the internet, namely:
http://blog.tlensing.org/2008/12/17/openframeworks-005-python-binding-for-os-x-105/
http://code.google.com/p/openframeworks-python-bindings/

and it was discussed in a previous thread, though the links are all dead now:
http://forum.openframeworks.cc/t/python-bindings-for-006,-osx/2763/0

How would you go about adapting these to a different build of OF?

Well I don’t know, but at least you have code to look at.
And what do you mean, links are dead? This one is not: https://github.com/johnglover/pyof
So go, fork it, and play. :slight_smile: Maybe underdoeg has some wisdom to share, since he commented in that thread, and seems to have used it.

That’s cool. I’d love to see python bindings for of! For sketching and demonstrating stuff, sometimes c++ can be a little overwhelming. Might also be a good way to snatch those processing users away :wink:

Maybe I still have my tests with the binding floating around somewhere. I did some minor changes though I’m not sure which ones. But I think what I did is described on https://github.com/johnglover/pyof#a-note-for-snow-leopard-users I’ll check if I still have the files when I get home.

Count me in with some help on the linux part, if you’re going to revive this project.

1 Like

+1 of python binding!

1 Like

interesting! Are there some news about? what is needed to develop a python bindings? i looked a bit here : https://github.com/johnglover/pyof , i haven’t much experience in python I wondering how to modify it for linux. What lib to import ? Swig is absolutely needed?
Thanks

There are different ways on how to create bindings. http://wiki.python.org/moin/IntegratingPythonWithOtherLanguages#C.2BAC8-C.2B-.2B--Binding-Generators

I did not yet dig too deeply into this, but AFAIK SWIG is great because it has utilities to create bindings automatically from .h files and is able to expose them not just to python but also lua, ruby, etc… On the other hand I fear that it is a little uber-automated and slower than other approaches. Just because it is rather old (though still very active) and more of a general purpose kind of toolkit.

Other tools like Boost.Python depend more on “hand work” to expose classes and functions.

I somehow feel like it might be worth exposing classes manually to really get “good” bindings that don’t feel somehow non python native or awkward, but that’s just a hunch without any foundation. :wink: maybe there is a way to create bindings in a way that they are editable afterwards?

This stackoverflow discussion is also interesting http://stackoverflow.com/questions/1492755/python-c-binding-library-comparison especially the answer by Christopher Bruns (btw how can I link answers in stackoverflow?)

Did anyone ever look more closely into binding python and knows more about pros and cons?

I still think it’d be great to get this to a mature state at some point. We were teaching a creative coding workshop last week with first time coders and decided to go with processing, although I hardly ever use it any more. processing is great but I somehow feel python-of might be even easier to use for teaching just because of the way python is designed and it would open the door to c++ for enthusiasts who want more…

in the lower left of the answer, there’s a “link” link: http://stackoverflow.com/a/7890051/599884

yeah python feels nice. I recently started learning it for plotting data with matplotlib; and I’m currently playing around with the github API via python. C++ would be much to cumbersome for that I think. Python feels immediate and good for exploration/playing/prototyping.

I second that. I’m having most trouble with introducing people to c++ not to OF. But I think getting a python binding isn’t hard, it’s the addons where most power comes from. How would addons get binded?

Rg,

Arnaud

I guess addons would have to be bound seperately. But maybe there is a way to ease that process?

Openframeworks already eases the path to get into c/c++ programming. This is accomplished by it’s file hierarchy for example (IMHO). If a python binding wants to be successful it really needs to pave the path for addons as well. Preferably a python addon binding should be made automatically. I’ve never done python bindings before except for some Blender stuff. Panda3D gets automatic Python bindings. How do they do it?

Another thing that is already really funcitonal is the lua bindings… https://github.com/danomatika/ofxLua

Personally I think I’d get along well with using lua. But in terms of beginner friendly I suspect that pyhton is much easier.