Python bindings?

Hi all,

I’ve been looking for a cross platform toolkit for my current projects (a couple of miditools). I’ve been looking at wxWidgets but I don’t like it much, I’d rather go with something a bit more modern and flexible. JUCE seems to be what I’ve been looking for. However, I prefer working in Python for such simple applications. So my question is, has someone started making Python bindings for JUCE? If not, is someone up to it?
I wish I had the time to do it right now, but I’m gigging a lot with the band and working full time so there’s not much time left. Not until after the summer.

Regards,
Henrik

I did ! I used SWIG to generate the wrapper. I currently have a VC++ Express project and a few scripts hanging around to call SWIG or call the python interpreter. Anyway, most of the paths are currently hardcoded and it is not ready to be made public.
Moreover, due to some limitations in SWIG, the whole library is not fully wrapped (it’s about 90% done).
I’m glad to see someone interrested in this too. I will drop a zip of the whole thing somewhere once everything is done.
If you anyone wants to, I can send them the project ‘as is’ by mail.

_john.

i would be interested too… :smiley:

Could you post it in a website, so we could all look at this ?

Sincerely,
Cyril

Sure … but where ? Could you propose something ? All I have is the home page storage space given by my ISP … Any other idea ?

_john, please check your PM.

Thanks

It is now available here.

John’s work is very impressive (almost everything is there). Pleace try the code, and report your experience.

John’s made the SWIG interface file.
So using swig allows using JUCE from any programming language (not only python but C, C#, VB, etc…). Just change the swig command line from

swig -c++ -python -modern -new_repr -cpluscast -dirprot -I..\juce_1_10 -o generated\JUCE_wrap.cpp -noh -outdir bin -v -Wall JUCE.i

to (for C#)

swig -c++ -csharp -modern -new_repr -cpluscast -dirprot -I..\juce_1_10 -o generated\JUCE_wrap.cpp -noh -outdir bin -v -Wall JUCE.i

Very impressive.

Hey, I think you are a bit optimistic :slight_smile:
Many parts of the bindings are python specific. I am sure the wrapper can’t work with other languages than Python !

Hey Guys,

I’m just wondering what’s happening with this. Do you have planes to finish it? I’m very interested because I don’t use C++ but I absolutely love Python.

Thanks!

-=GB=-

I’ll finish it as far as I need it but I don’t want to do some kind of full coverage test of what SWIG has generated : this wrapper is someting I write for my own needs, nothing more.
It means that even when I’ll consider it’s done, there still will be some badly wrapped classes that would need to be wrapped manually. I’m also sure that some parts will remain buggy so being an early adopter of this wrapper would mean you know enough of C++ to track existing bugs up to the C++ code (most of this code it automaticaly generated but still quite readable), either to fix them (great !) or simply report it as clearly as possible.
Shortly, "when it’s done’ is the only release date I’m sure of, and don’t expect a production grade version for the first release.

Anyone please contact me if they are interrested by this project and would like to give a hand.

Well, thanks for getting it started anyway. :wink: You got pretty far as far as I can tell. I noticed that there’s no GL window in there. I’ll have to put that one in. I’ll post whatever I add in this thread. I might also try and separate a few things into different modules. Like the GUI, audio, process and file or something like that so we can just import what we need. I’ve found this helps a lot if you’re using the Psycho module.

Thanks again! I really hope this catches on.

I’ve used psyco a lot on Linux, and I didn’t know it existed on Window. I’m currently trying to put up a website (it will be on tuxfamily). My first idea was to split the wrapper in many modules, but I don’t know SWIG enough for that and I wanted to have something I could use fast. Please go on, any patches are welcome :wink: !

Some news here : http://pyjuce.tuxfamily.org/
(it’s a simple website with news, a bugtracker and a public CVS)
Any comments (and help) are welcome !
I spent most of my spare time these days setting up the website so the code hasn’t changed much, but I’ll do an update for JUCE v1.12 as soon as possible.

Hi
I’m new to Python and Bindings, but thought i’d try this out…

I can create a TextButton and access TextButton’s methods, but not any parent (Button’s or Component, etc) methods…

for example:

testButton = JUCE.TextButton(“Hello”, JUCE.Colours.black, UCE.Colours.grey, JUCE.Colours.red, “Tooltop”) # this works

testButton.setButtonText(“changed the name”) # this also works

testButton.setBounds(100,100,50,50) #this doesn’t work

any idea what i’m doing wrong here? it’s probably something pretty simple

thanks

I would simply call it like that :
textButton.Component.setBounds(etc…)

I don’t understand your problem exactly. Are you trying to call setBounds on the init ? Then, you’ll have to specify the base class or use super() keyword.

Well, yes, that’s what i expected, too…
but it still doesn’t work.

ie.,
testButton = JUCE.TextButton(“Hello”, JUCE.Colours.black, UCE.Colours.grey, JUCE.Colours.red, “hi”) testButton.Component.setBounds(100,100,50,50)

fails with "AttributeError: ‘TextButton’ object has no attribute ‘Component’

any other ideas?
thanks

If swig was used without flags, then I think the correct use will be :

component.Component_setBounds(textButton, 1,2,3,4);

I’ve found this in the SWIG documentation.

class Shape {
public:
        double x,y;
	virtual double area() = 0;
	virtual double perimeter() = 0;
	void    set_location(double x, double y);
};
class Circle : public Shape {
public:
	Circle(double radius);
	~Circle();
	double area();
	double perimeter();
};
class Square : public Shape {
public:
	Square(double size);
	~Square();
	double area();
	double perimeter();
}

which is used like this once transformed

$ python
>>> import shapes
>>> circle = shapes.new_Circle(7)
>>> square = shapes.new_Square(10)
>>> print shapes.Circle_area(circle)
153.93804004599999757
>>> print shapes.Shape_area(circle)
153.93804004599999757
>>> print shapes.Shape_area(square)
100.00000000000000000
>>> shapes.Shape_set_location(square,2,-3)
>>> print shapes.Shape_perimeter(square)
40.00000000000000000
>>>

Well, sorry for not answering earlier.

myButton.setBounds(100,100,50,50) is the correct way of calling.
I’ll go and check this evening what’s wrong. Anyway, SWIG has got a lot of problems with the Button class (some method wrappers are generated twice, etc.) and I think I’ll write the wrapper manualy for next releases :slight_smile:

It’s out: http://pyjuce.tuxfamily.org/templeet/pyjuce/
… or simply pyjuce.tuxfamily.org/release/pyJUCE-0.0.2.zip.

Seeing as the zip file only includes a .dll, I’m assuming that pyjuce has only been developed for windows.

I’m interested in developing a mac osx version of pyjuce but I have little experience in creating software bindings.

Is it a simple matter of turning on a osx switch in the make file from the pyjuce source or would I need to develop a mac version of pyjuce from scratch?

To develop a mac version of pyjuce is it simply a matter of finding the right flags for py++ or swig (a one hour job) or would there be alot of manual coding required (a 100 hour job)?