Sign in to follow this  
Misery

Scriptnig language api

Recommended Posts

Hi,
I have integrated python with my c++ (with Qt) application.
I wonder how to make an api, so it was possible to have influence on
application behavior.
f.ex. Lets say I have in my application an object Edit from TEdit class.
And it has a font property.
How to make this classes and instances seen for python so I (or rather user) could run a script with something like that:

...
Edit.font.Type="Times new roman"
...


thanks for help :]


Share this post


Link to post
Share on other sites
If you're using PyQt or PySide the easiest thing to do is to define your TEdit class in Python rather than C++.

Otherwise I think you'll have to crated Python bindings for the C++ object. One way of doing this is to use Boost.Python, which is a little bit simpler that using Python's native FFI. If you only have one or two things you need to expose from a C dll, you might be able to get away with using ctypes.

Disclaimer: I've never used Qt with Python.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this