Results 1 to 4 of 4

Thread: Suggestions for wrapping C++ code for use with Python3

  1. #1
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,235
    Thanks
    303
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Suggestions for wrapping C++ code for use with Python3

    I am looking for suggestions for the preferred tool for wrapping C++ code so that it can be called from Python3. I have a very large C++ library and I would like to expose some parts of it to Python 3 for rapid prototyping purposes. I've looked into boost.python and Cython and I know there are others, but I have no experience to guide me.

    I also don't know what tool is used to prepare the Python wrappers for Qt; I would like to check that out.

    Finally, in my ideal universe, all I would have to do is to point some tool at a directory and say, "expose every class and every public method of those classes to Python" and voila, there it is.

    Any suggestions (along with rationale) would be appreciated.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,235
    Thanks
    303
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Suggestions for wrapping C++ code for use with Python3

    I see that Qt uses the Shiboken2 tool to create PySide Qt bindings. So I guess if it is good enough for Qt, I'll have to look into it.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3

    Default Re: Suggestions for wrapping C++ code for use with Python3

    You can check this https://www.qt.io/qt-for-python for used to prepare the Python wrappers for Qt and how do you use Qt Creator in Python: Open Qt Creator and go to Tools->Options->Environment->External Tools . Click Add->Add category and create a new category (for example, Python ). Then, select the created category and click Add->Add Tool to create a new tool - RunPy for example.

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,235
    Thanks
    303
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Suggestions for wrapping C++ code for use with Python3

    You can check this https://www.qt.io/qt-for-python for used to prepare the Python wrappers for Qt and how do you use Qt Creator in Python
    Thanks, but this shows how to set up Qt Creator for using the existing Pyside2 bindings and Python environment. My question was how to create my own bindings for my own Qt-based classes.

    If you know of any automated tool for generating Python bindings from a C++ Qt class definition, I would like to know about that, not how to use Python inside of Qt Creator. From what I read of the Shiboken2 documentation, using it to generate bindings for anything except trivial classes would be a huge project. I have a library with hundreds of classes and a thousand or more functions. If I have to hand-code a typesystem file for Shiboken -and- keep that up-to-date with any changes I make on the C++ side, it would take me forever.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Install Qt from source - Enable Python3 and Disable Python2?
    By jiapei100 in forum Installation and Deployment
    Replies: 0
    Last Post: 14th January 2020, 07:34
  2. ActiveQt Wrapping
    By ComaWhite in forum Qt Programming
    Replies: 1
    Last Post: 3rd November 2010, 10:36
  3. Wrapping Qt into a dll
    By spatten in forum Qt Programming
    Replies: 1
    Last Post: 29th June 2010, 19:09
  4. Wrapping Qt
    By OlivierREVOL in forum General Discussion
    Replies: 2
    Last Post: 4th June 2009, 21:55
  5. Wrapping while printing
    By veda in forum Qt Programming
    Replies: 3
    Last Post: 18th September 2007, 15:37

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.