Orange Forum • View topic - Intergrating C++ with Python in Orange

Intergrating C++ with Python in Orange

A place to ask questions about methods in Orange and how they are used and other general support.

Intergrating C++ with Python in Orange

Postby Guest » Fri Oct 14, 2005 9:15

I am writing certain scripts in c++ to help filter the data. My question is how can Intergrate c++ code with python so I am able to create wigdets within Orange.

Thank You

Postby Janez » Sun Oct 16, 2005 9:29

Do you want your code to use Orange objects or not? That is, will your function(s) take instances of, say, orange.ExampleTable as arguments and/or return them as a result?

Postby Guest » Tue Oct 18, 2005 8:28

Yes my program will call orange objects ...

Postby Janez » Mon Oct 24, 2005 20:00

There is a draft of documentation for that - take a look at I'm not 100% sure that it is all up-to-date, and it's certainly not finished, full of typeos... You may also want to take a look at the files in directory "orangene", which can serve as an example for deriving new classes and exporting them to python.

Basically, what you need to do is to

1. Program your filter in a similar manner than the filters in filter.cpp (I understand that this is what you intend, right?)

2. See how the filters are exported to Python (you will find it in lib_kernel.cpp - probably you won't need to write anything but something like
Code: Select all
C_CALL(Filter_hasClassValue, Filter, "([examples], [negate=..., domain=...]) -/-> ExampleTable")

3. See the files in directory orangene for an example of how to use and (our own swig-like tools) to prepare the python interface.

If you have any problems, and if you plan to write a subclass of filter, I can write a simple demo filter (I have to write a few examples like this and add it to the documentation anyway).

Postby Janez » Tue Oct 25, 2005 1:16

I have prepared a simple demo - it's a new python module that defines three classes which are derived from orange objects, they get orange objects as arguments and also return orange objects. You can download it from

1. Extract it to directory orange/source/mymodules (you will need the orange sources for this).
2. Don't forget to run _pytxtract.bat
3. Load the .dsw to Visual studio and build (if you build the debug version you will also need the debug build of Python).

If you want to program your own filters/learners ... you can take these sources and modify it.

I have also updated the documentation I wrote about in the previous mail, so you may want to look at the new version on the web.

Due to a bug in the pyxtract and pyprops, the module name cannot contain upper-case letters.

Please tell me if you have any problems with the demo.

Return to Questions & Support